From f8b85edd0cdf87c9f9a8507258b7989023d028bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Mon, 4 Aug 2025 19:34:31 +0200 Subject: Qt: Better wayland detection to enforce xcb In certain cases, the platform can be "wayland-egl", "wayland-xcomposite", and other values for which I haven't found a full list yet. Instead of matching only "wayland", we now look for "wayland" anywhere in the `QT_QPA_PLATFORM` string in a case-insensitive manner. Acknowledgements: `CaseInsensitiveContains`' implementation was heavily inspired by GNU's non-standard glibc `strcasestr` function, which can be found here licensed under GPLv2 or later: https://ftp.gnu.org/gnu/libc/ --- Source/UnitTests/Common/StringUtilTest.cpp | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Source/UnitTests/Common/StringUtilTest.cpp') diff --git a/Source/UnitTests/Common/StringUtilTest.cpp b/Source/UnitTests/Common/StringUtilTest.cpp index 2be462a1b5..28bd150c06 100644 --- a/Source/UnitTests/Common/StringUtilTest.cpp +++ b/Source/UnitTests/Common/StringUtilTest.cpp @@ -225,3 +225,34 @@ TEST(StringUtil, SplitPathWindowsPathWithDriveLetter) EXPECT_EQ(extension, ""); } #endif + +TEST(StringUtil, CaseInsensitiveContains_BasicMatches) +{ + EXPECT_TRUE(Common::CaseInsensitiveContains("hello world", "hello")); + EXPECT_TRUE(Common::CaseInsensitiveContains("hello world", "world")); + EXPECT_TRUE(Common::CaseInsensitiveContains("HELLO WORLD", "hello")); + EXPECT_TRUE(Common::CaseInsensitiveContains("HeLLo WoRLd", "WORLD")); +} + +TEST(StringUtil, CaseInsensitiveContains_SubstringNotFound) +{ + EXPECT_FALSE(Common::CaseInsensitiveContains("hello world", "hey")); +} + +TEST(StringUtil, CaseInsensitiveContains_EmptyStrings) +{ + EXPECT_TRUE(Common::CaseInsensitiveContains("", "")); + EXPECT_TRUE(Common::CaseInsensitiveContains("hello", "")); + EXPECT_FALSE(Common::CaseInsensitiveContains("", "world")); +} + +TEST(StringUtil, CaseInsensitiveContains_EntireStringMatch) +{ + EXPECT_TRUE(Common::CaseInsensitiveContains("Test", "TEST")); +} + +TEST(StringUtil, CaseInsensitiveContains_OverlappingMatches) +{ + EXPECT_TRUE(Common::CaseInsensitiveContains("aaaaaa", "aa")); + EXPECT_TRUE(Common::CaseInsensitiveContains("ababababa", "bABa")); +} -- cgit v1.2.3