aboutsummaryrefslogtreecommitdiff
path: root/zencore/string.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-10-25 09:39:31 +0200
committerMartin Ridgers <[email protected]>2021-10-25 09:48:30 +0200
commitc80bc1e4b2ea10c2e871091f996d19a18218f231 (patch)
treef3487b5588c30167ac8278c6079bb8b334f669f7 /zencore/string.cpp
parentMerged main (diff)
downloadzen-c80bc1e4b2ea10c2e871091f996d19a18218f231.tar.xz
zen-c80bc1e4b2ea10c2e871091f996d19a18218f231.zip
Cross-platform string comparison helper plus tests
Diffstat (limited to 'zencore/string.cpp')
-rw-r--r--zencore/string.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/zencore/string.cpp b/zencore/string.cpp
index 34ea0a87d..35dfcfcf3 100644
--- a/zencore/string.cpp
+++ b/zencore/string.cpp
@@ -951,6 +951,18 @@ TEST_CASE("string")
CHECK_EQ(ToLower("TE%St"sv), "te%st"sv);
}
+ SUBCASE("StrCaseCompare")
+ {
+ CHECK(StrCaseCompare("foo", "FoO") == 0);
+ CHECK(StrCaseCompare("Bar", "bAs") < 0);
+ CHECK(StrCaseCompare("bAr", "Bas") < 0);
+ CHECK(StrCaseCompare("BBr", "Bar") > 0);
+ CHECK(StrCaseCompare("Bbr", "BAr") > 0);
+ CHECK(StrCaseCompare("foo", "FoO", 3) == 0);
+ CHECK(StrCaseCompare("Bar", "bAs", 3) < 0);
+ CHECK(StrCaseCompare("BBr", "Bar", 2) > 0);
+ }
+
SUBCASE("ForEachStrTok")
{
const auto Tokens = "here,is,my,different,tokens"sv;