From e088e01ace0f6d8ebdb2c47f8e31de46b21bc1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Heskestad?= Date: Thu, 5 Jan 2023 16:54:12 +0100 Subject: [PATCH] Accept U+2212 as minus sign in negative year unit test Not all locales use ASCII hyphen-minus U+002D as minus sign. On macOS using the nb_NO locale the U+2212 character is used instead when displaying negative years. Verify that one of the two characters is found. Fixes: QTBUG-109853 Change-Id: I424539cc8d427ac199b4528e44bef98e45312d07 Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index ed5cbbe2104..442e1169805 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -2789,7 +2789,11 @@ void tst_QLocale::dateFormat() // And, indeed, one for a negative year: old = sys.toString(QDate(-1173, 5, 1), QLocale::LongFormat); QVERIFY(!old.isEmpty()); - QVERIFY2(old.contains(u"-1173"), qPrintable(old + QLatin1String(" for locale ") + sys.name())); + qsizetype yearDigitStart = old.indexOf(u"1173"); + QVERIFY2(yearDigitStart != -1, qPrintable(old + QLatin1String(" for locale ") + sys.name())); + QStringView before = QStringView(old).first(yearDigitStart); + QVERIFY2(before.endsWith(QChar('-')) || before.endsWith(QChar(0x2212)), + qPrintable(old + QLatin1String(" has no minus sign for locale ") + sys.name())); } void tst_QLocale::timeFormat()