From e46ba4d413050e1afcf5eaee0e581a5dbd3e3b50 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 19 Oct 2024 10:53:36 +0200 Subject: [PATCH] tst_QChar: run it also under QT_RESTRICTED_CAST_FROM_ASCII Like QString, QChar also changes API when said macro is defined. So, like tst_QString from 8420d3e0b205d0ef2367224afd3040c68e28bcc9 onwards, also compile tst_QChar under it, separately. Pick-to: 6.5 Change-Id: I81d25d5bfae78b1a11d47e49aa618d079c4b09b7 Reviewed-by: Ahmad Samir Reviewed-by: Thiago Macieira (cherry picked from commit 167b04aac89488a5f2005bd1f4dfde354f43c6a6) --- tests/auto/corelib/text/qchar/CMakeLists.txt | 22 ++++++++++++++------ tests/auto/corelib/text/qchar/tst_qchar.cpp | 5 +++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/text/qchar/CMakeLists.txt b/tests/auto/corelib/text/qchar/CMakeLists.txt index 03b99356ea8..de10b49625f 100644 --- a/tests/auto/corelib/text/qchar/CMakeLists.txt +++ b/tests/auto/corelib/text/qchar/CMakeLists.txt @@ -14,10 +14,20 @@ endif() # Collect test data list(APPEND test_data "data/NormalizationTest.txt") -qt_internal_add_test(tst_qchar - SOURCES - tst_qchar.cpp - LIBRARIES - Qt::CorePrivate - TESTDATA ${test_data} +foreach(test tst_qchar tst_qchar_restricted_ascii) + qt_internal_add_test(${test} + NO_BATCH + SOURCES + tst_qchar.cpp + LIBRARIES + Qt::CorePrivate + TESTDATA + ${test_data} + ) +endforeach() + +qt_internal_extend_target(tst_qchar_restricted_ascii + DEFINES + QT_RESTRICTED_CAST_FROM_ASCII + tst_QChar=tst_QChar_restricted_ascii ) diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp index 3428988f858..c6ae668ca6d 100644 --- a/tests/auto/corelib/text/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp @@ -6,6 +6,7 @@ #include #include +#include #include template @@ -33,7 +34,11 @@ static_assert(explicitly); // // Conversion from others // +#if defined(QT_RESTRICTED_CAST_FROM_ASCII) +static_assert(explicitly); // via integer promotion +#else static_assert(explicitly); +#endif static_assert(implicitly); static_assert(implicitly); static_assert(explicitly);