Files
OpenAssetTools/test/CommonTests/Utils/StringUtilsTests.cpp
T
elliot 28b14ea0ee 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
2026-10-18 22:51:52 +02:00

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("@", "`"));
}
}