From d697280493b7a2187ba46035a209cda68ee532a0 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 4 May 2025 08:22:20 +0200 Subject: [PATCH] Codechange: remove now obsolete char* tests The function is std::string_view and there are std::string_view tests as well. --- src/tests/string_func.cpp | 100 ++------------------------------------ 1 file changed, 4 insertions(+), 96 deletions(-) diff --git a/src/tests/string_func.cpp b/src/tests/string_func.cpp index 69b1ef3bc8..17d35ed35b 100644 --- a/src/tests/string_func.cpp +++ b/src/tests/string_func.cpp @@ -47,30 +47,6 @@ TEST_CASE("StrCompareIgnoreCase - std::string") CHECK(StrCompareIgnoreCase(std::string{"aa"}, std::string{"a"}) > 0); } -TEST_CASE("StrCompareIgnoreCase - char pointer") -{ - /* Same string, with different cases. */ - CHECK(StrCompareIgnoreCase("", "") == 0); - CHECK(StrCompareIgnoreCase("a", "a") == 0); - CHECK(StrCompareIgnoreCase("a", "A") == 0); - CHECK(StrCompareIgnoreCase("A", "a") == 0); - CHECK(StrCompareIgnoreCase("A", "A") == 0); - - /* Not the same string. */ - CHECK(StrCompareIgnoreCase("", "b") < 0); - CHECK(StrCompareIgnoreCase("a", "") > 0); - - CHECK(StrCompareIgnoreCase("a", "b") < 0); - CHECK(StrCompareIgnoreCase("b", "a") > 0); - CHECK(StrCompareIgnoreCase("a", "B") < 0); - CHECK(StrCompareIgnoreCase("b", "A") > 0); - CHECK(StrCompareIgnoreCase("A", "b") < 0); - CHECK(StrCompareIgnoreCase("B", "a") > 0); - - CHECK(StrCompareIgnoreCase("a", "aa") < 0); - CHECK(StrCompareIgnoreCase("aa", "a") > 0); -} - TEST_CASE("StrCompareIgnoreCase - std::string_view") { /* @@ -78,7 +54,7 @@ TEST_CASE("StrCompareIgnoreCase - std::string_view") * which does not guarantee the termination that would be required by * things such as stricmp/strcasecmp. So, just passing .data() into stricmp * or strcasecmp would fail if it does not account for the length of the - * view. Thus, contrary to the string/char* tests, this uses the same base + * view. Thus, contrary to the string tests, this uses the same base * string but gets different sections to trigger these corner cases. */ std::string_view base{"aaAbB"}; @@ -123,24 +99,6 @@ TEST_CASE("StrEqualsIgnoreCase - std::string") CHECK(!StrEqualsIgnoreCase(std::string{"aa"}, std::string{"a"})); } -TEST_CASE("StrEqualsIgnoreCase - char pointer") -{ - /* Same string, with different cases. */ - CHECK(StrEqualsIgnoreCase("", "")); - CHECK(StrEqualsIgnoreCase("a", "a")); - CHECK(StrEqualsIgnoreCase("a", "A")); - CHECK(StrEqualsIgnoreCase("A", "a")); - CHECK(StrEqualsIgnoreCase("A", "A")); - - /* Not the same string. */ - CHECK(!StrEqualsIgnoreCase("", "b")); - CHECK(!StrEqualsIgnoreCase("a", "")); - CHECK(!StrEqualsIgnoreCase("a", "b")); - CHECK(!StrEqualsIgnoreCase("b", "a")); - CHECK(!StrEqualsIgnoreCase("a", "aa")); - CHECK(!StrEqualsIgnoreCase("aa", "a")); -} - TEST_CASE("StrEqualsIgnoreCase - std::string_view") { /* @@ -148,7 +106,7 @@ TEST_CASE("StrEqualsIgnoreCase - std::string_view") * which does not guarantee the termination that would be required by * things such as stricmp/strcasecmp. So, just passing .data() into stricmp * or strcasecmp would fail if it does not account for the length of the - * view. Thus, contrary to the string/char* tests, this uses the same base + * view. Thus, contrary to the string tests, this uses the same base * string but gets different sections to trigger these corner cases. */ std::string_view base{"aaAb"}; @@ -196,31 +154,6 @@ TEST_CASE("StrStartsWithIgnoreCase - std::string") CHECK(!StrStartsWithIgnoreCase(std::string{"a"}, std::string{"aa"})); } -TEST_CASE("StrStartsWithIgnoreCase - char pointer") -{ - /* Everything starts with an empty prefix. */ - CHECK(StrStartsWithIgnoreCase("", "")); - CHECK(StrStartsWithIgnoreCase("a", "")); - - /* Equals string, ignoring case. */ - CHECK(StrStartsWithIgnoreCase("a", "a")); - CHECK(StrStartsWithIgnoreCase("a", "A")); - CHECK(StrStartsWithIgnoreCase("A", "a")); - CHECK(StrStartsWithIgnoreCase("A", "A")); - - /* Starts with same, ignoring case. */ - CHECK(StrStartsWithIgnoreCase("ab", "a")); - CHECK(StrStartsWithIgnoreCase("ab", "A")); - CHECK(StrStartsWithIgnoreCase("Ab", "a")); - CHECK(StrStartsWithIgnoreCase("Ab", "A")); - - /* Does not start the same. */ - CHECK(!StrStartsWithIgnoreCase("", "b")); - CHECK(!StrStartsWithIgnoreCase("a", "b")); - CHECK(!StrStartsWithIgnoreCase("b", "a")); - CHECK(!StrStartsWithIgnoreCase("a", "aa")); -} - TEST_CASE("StrStartsWithIgnoreCase - std::string_view") { /* @@ -228,7 +161,7 @@ TEST_CASE("StrStartsWithIgnoreCase - std::string_view") * which does not guarantee the termination that would be required by * things such as stricmp/strcasecmp. So, just passing .data() into stricmp * or strcasecmp would fail if it does not account for the length of the - * view. Thus, contrary to the string/char* tests, this uses the same base + * view. Thus, contrary to the string tests, this uses the same base * string but gets different sections to trigger these corner cases. */ std::string_view base{"aabAb"}; @@ -283,31 +216,6 @@ TEST_CASE("StrEndsWithIgnoreCase - std::string") CHECK(!StrEndsWithIgnoreCase(std::string{"a"}, std::string{"aa"})); } -TEST_CASE("StrEndsWithIgnoreCase - char pointer") -{ - /* Everything ends with an empty prefix. */ - CHECK(StrEndsWithIgnoreCase("", "")); - CHECK(StrEndsWithIgnoreCase("a", "")); - - /* Equals string, ignoring case. */ - CHECK(StrEndsWithIgnoreCase("a", "a")); - CHECK(StrEndsWithIgnoreCase("a", "A")); - CHECK(StrEndsWithIgnoreCase("A", "a")); - CHECK(StrEndsWithIgnoreCase("A", "A")); - - /* Ends with same, ignoring case. */ - CHECK(StrEndsWithIgnoreCase("ba", "a")); - CHECK(StrEndsWithIgnoreCase("ba", "A")); - CHECK(StrEndsWithIgnoreCase("bA", "a")); - CHECK(StrEndsWithIgnoreCase("bA", "A")); - - /* Does not end the same. */ - CHECK(!StrEndsWithIgnoreCase("", "b")); - CHECK(!StrEndsWithIgnoreCase("a", "b")); - CHECK(!StrEndsWithIgnoreCase("b", "a")); - CHECK(!StrEndsWithIgnoreCase("a", "aa")); -} - TEST_CASE("StrEndsWithIgnoreCase - std::string_view") { /* @@ -315,7 +223,7 @@ TEST_CASE("StrEndsWithIgnoreCase - std::string_view") * which does not guarantee the termination that would be required by * things such as stricmp/strcasecmp. So, just passing .data() into stricmp * or strcasecmp would fail if it does not account for the length of the - * view. Thus, contrary to the string/char* tests, this uses the same base + * view. Thus, contrary to the string tests, this uses the same base * string but gets different sections to trigger these corner cases. */ std::string_view base{"aabAba"};