aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
authorChris Gyurgyik <37983775+cgyurgyik@users.noreply.github.com>2020-07-31 14:57:46 -0400
committerGitHub <noreply@github.com>2020-07-31 14:57:46 -0400
commit7212ad067e6efcd8431a9e38f26de45ae21eeafb (patch)
tree41ad236212c14308d13f28ac8db2feda2609a48a /libc/test
parentca6b6d40ffba27fe231f55f7edc533f0a1815d31 (diff)
downloadllvm-project-7212ad067e6efcd8431a9e38f26de45ae21eeafb.tar.gz
[libc] [obvious] Add rest of strrchr test.
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/src/string/strrchr_test.cpp7
1 files changed, 5 insertions, 2 deletions
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) {