mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-10-24 12:38:10 +00:00
fix: make StringEqualsIgnoreCase constexpr (#1021)
* fix: make StringEqualsIgnoreCase constexpr Move utils::StringEqualsIgnoreCase into the header as a constexpr function using an ASCII-only lowercase helper, so it can be used from constexpr contexts such as InfoString's comparators with newer MSVC toolsets. * test: add StringEqualsIgnoreCase tests
This commit is contained in:
1 parent
bc0a786444
commit
28b14ea0ee
3 files changed
+38
-14
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
static_assert(utils::StringEqualsIgnoreCase("", ""));
|
||||
static_assert(utils::StringEqualsIgnoreCase("Hello World", "hELLO wORLD"));
|
||||
static_assert(!utils::StringEqualsIgnoreCase("Hello", "Hello World"));
|
||||
static_assert(!utils::StringEqualsIgnoreCase("[", "{"));
|
||||
|
||||
TEST_CASE("StringUtils: StringEqualsIgnoreCase", "[stringutils]")
|
||||
{
|
||||
SECTION("matches strings that only differ in case")
|
||||
{
|
||||
REQUIRE(utils::StringEqualsIgnoreCase("mp_rust", "MP_Rust"));
|
||||
REQUIRE(utils::StringEqualsIgnoreCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
|
||||
SECTION("does not match different strings")
|
||||
{
|
||||
REQUIRE_FALSE(utils::StringEqualsIgnoreCase("mp_rust", "mp_rust2"));
|
||||
REQUIRE_FALSE(utils::StringEqualsIgnoreCase("@", "`"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user