Added to string_util tests corner cases for empty strings and numerics (#3180)

This commit is contained in:
jasonjyu 2024-10-27 06:33:45 -04:00 committed by GitHub
parent 552d81dd56
commit f59f509923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 1 deletions

View File

@ -14,20 +14,37 @@ TEST(String, ends_with) {
}
TEST(String, upper) {
EXPECT_EQ("", string_util::upper(""));
EXPECT_EQ("FOO", string_util::upper("FOO"));
EXPECT_EQ("FOO", string_util::upper("FoO"));
EXPECT_EQ("FOO", string_util::upper("FOo"));
EXPECT_EQ("FOO", string_util::upper("Foo"));
EXPECT_EQ("FOO", string_util::upper("fOO"));
EXPECT_EQ("FOO", string_util::upper("foO"));
EXPECT_EQ("FOO", string_util::upper("fOo"));
EXPECT_EQ("FOO", string_util::upper("foo"));
EXPECT_EQ("123", string_util::upper("123"));
}
TEST(String, lower) {
EXPECT_EQ("bar", string_util::lower("BAR"));
EXPECT_EQ("", string_util::lower(""));
EXPECT_EQ("bar", string_util::lower("BaR"));
EXPECT_EQ("bar", string_util::lower("BAr"));
EXPECT_EQ("bar", string_util::lower("Bar"));
EXPECT_EQ("bar", string_util::lower("bAR"));
EXPECT_EQ("bar", string_util::lower("baR"));
EXPECT_EQ("bar", string_util::lower("bAr"));
EXPECT_EQ("bar", string_util::lower("bar"));
EXPECT_EQ("123", string_util::upper("123"));
}
TEST(String, compare) {
EXPECT_TRUE(string_util::compare("", ""));
EXPECT_TRUE(string_util::compare("foo", "foo"));
EXPECT_TRUE(string_util::compare("foo", "Foo"));
EXPECT_TRUE(string_util::compare("123", "123"));
EXPECT_FALSE(string_util::compare("foo", "bar"));
EXPECT_FALSE(string_util::compare("123", "456"));
}
TEST(String, contains) {