From f59f509923302349da07133d8c41cc3675ecd639 Mon Sep 17 00:00:00 2001 From: jasonjyu Date: Sun, 27 Oct 2024 06:33:45 -0400 Subject: [PATCH] Added to string_util tests corner cases for empty strings and numerics (#3180) --- tests/unit_tests/utils/string.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/utils/string.cpp b/tests/unit_tests/utils/string.cpp index de7a1825..76104e91 100644 --- a/tests/unit_tests/utils/string.cpp +++ b/tests/unit_tests/utils/string.cpp @@ -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) {