Skip to content

Commit

Permalink
Update search tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Apr 16, 2024
1 parent 104c87c commit 0542dee
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/testSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,59 @@ TEST(LiteStringSearchTest, FindSubstrCStrReturnsMaxSize) {
EXPECT_EQ(string_find_cstr(s, "Planet"), lite_string_npos);
string_free(s);
}

TEST(LiteStringTest, FindFirstOfCStrReturnsCorrectIndex) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_first_of_chars(s, "World");
EXPECT_EQ(index, 2);
string_free(s);
}

TEST(LiteStringTest, FindFirstOfCStrReturnsNposWhenNotFound) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_first_of_chars(s, "XYZ");
EXPECT_EQ(index, lite_string_npos);
string_free(s);
}

TEST(LiteStringTest, FindFirstNotOfCStrReturnsCorrectIndex) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_first_not_of_chars(s, "Helo, ");
EXPECT_EQ(index, 7);
string_free(s);
}

TEST(LiteStringTest, FindFirstNotOfCStrReturnsNposWhenNotFound) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_first_not_of_chars(s, "Hello, World!");
EXPECT_EQ(index, lite_string_npos);
string_free(s);
}

TEST(LiteStringTest, FindLastOfCStrReturnsCorrectIndex) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_last_of_chars(s, "World");
EXPECT_EQ(index, 11);
string_free(s);
}

TEST(LiteStringTest, FindLastOfCStrReturnsNposWhenNotFound) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_last_of_chars(s, "XYZ");
EXPECT_EQ(index, lite_string_npos);
string_free(s);
}

TEST(LiteStringTest, FindLastNotOfCStrReturnsCorrectIndex) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_last_not_of_chars(s, "!dlroW");
EXPECT_EQ(index, 6);
string_free(s);
}

TEST(LiteStringTest, FindLastNotOfCStrReturnsNposWhenNotFound) {
lite_string* s = string_new_cstr("Hello, World!");
const size_t index = string_find_last_not_of_chars(s, "Hello, World!");
EXPECT_EQ(index, lite_string_npos);
string_free(s);
}

0 comments on commit 0542dee

Please sign in to comment.