[libc-commits] [libc] 7212ad0 - [libc] [obvious] Add rest of strrchr test.

via libc-commits libc-commits at lists.llvm.org
Fri Jul 31 11:57:49 PDT 2020


Author: Chris Gyurgyik
Date: 2020-07-31T14:57:46-04:00
New Revision: 7212ad067e6efcd8431a9e38f26de45ae21eeafb

URL: https://github.com/llvm/llvm-project/commit/7212ad067e6efcd8431a9e38f26de45ae21eeafb
DIFF: https://github.com/llvm/llvm-project/commit/7212ad067e6efcd8431a9e38f26de45ae21eeafb.diff

LOG: [libc] [obvious] Add rest of strrchr test.

Added: 
    

Modified: 
    libc/test/src/string/strrchr_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/string/strrchr_test.cpp b/libc/test/src/string/strrchr_test.cpp
index 18fddda60087..cf29de220d49 100644
--- a/libc/test/src/string/strrchr_test.cpp
+++ b/libc/test/src/string/strrchr_test.cpp
@@ -49,12 +49,15 @@ TEST(StrRChrTest, FindsNullTerminator) {
   ASSERT_STREQ(src, src_copy);
 }
 
-TEST(StrRChrTest, FindsLastNullTerminator) {
-  const char src[5] = {'a', '\0', 'b', '\0', 'c'};
+TEST(StrRChrTest, FindsLastBehindFirstNullTerminator) {
+  const char src[6] = {'a', 'a', '\0', 'b', '\0', 'c'};
   // 'b' is behind a null terminator, so should not be found.
   ASSERT_STREQ(__llvm_libc::strrchr(src, 'b'), nullptr);
   // Same goes for 'c'.
   ASSERT_STREQ(__llvm_libc::strrchr(src, 'c'), nullptr);
+  
+  // Should find the second of the two a's.
+  ASSERT_STREQ(__llvm_libc::strrchr(src, 'a'), "a");
 }
 
 TEST(StrRChrTest, CharacterNotWithinStringShouldReturnNullptr) {


        


More information about the libc-commits mailing list