mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-10-24 04:28:10 +00:00
* 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
24 lines
850 B
C++
24 lines
850 B
C++
#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("@", "`"));
|
|
}
|
|
}
|