Add a unit test for the shared text helpers

contains_ci and narrow/widen were centralized into shared headers
(ui/text_match.hpp, util/utf8.hpp) during the cleanup but had no
focused test, unlike the project's other pure-logic helpers. Cover the
filter contract the Log/Injection panels depend on (empty/null needle
matches all, case-insensitivity both directions, boundary substrings,
non-matches) and a narrow<->widen round-trip.

The non-ASCII round-trips (cafe.exe, CJK) would fail against the old
lossy `c & 0x7F` narrowing this cleanup replaced, so the test guards
that fix, not just the happy path. Registered as test #34; suite green.
This commit is contained in:
2026-07-12 10:02:53 +02:00
parent ed6312b657
commit c684a15fb9
2 changed files with 74 additions and 0 deletions

View File

@@ -207,6 +207,12 @@ add_executable(srgb_format_test srgb_format_test.cpp)
target_include_directories(srgb_format_test PRIVATE ${CMAKE_SOURCE_DIR}/host/src)
add_test(NAME srgb_format_test COMMAND srgb_format_test)
# Unit test for the host's shared text helpers: contains_ci (the panels' case-insensitive filter)
# and narrow/widen (UTF-8 <-> wide). Pure logic; header-only, no window / device.
add_executable(text_util_test text_util_test.cpp)
target_include_directories(text_util_test PRIVATE ${CMAKE_SOURCE_DIR}/host/src)
add_test(NAME text_util_test COMMAND text_util_test)
# Unit test for the keyed-mutex acquire decision (capture/keyed_mutex.hpp): WAIT_ABANDONED must be
# treated as "acquired" so a mirror recovers after a host crash instead of freezing. Header-only.
add_executable(keyed_mutex_test keyed_mutex_test.cpp)
@@ -405,6 +411,7 @@ coop_output_subdir(tests
audio_loopback_test
audio_hook_test
srgb_format_test
text_util_test
present_hook_test
dx12_present_hook_test
d3d9_hook_test