Skip to content

Commit

Permalink
[libc] [obvious] Add rest of strrchr test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgyurgyik committed Jul 31, 2020
1 parent ca6b6d4 commit 7212ad0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libc/test/src/string/strrchr_test.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit 7212ad0

Please sign in to comment.