summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qlocale
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-01-24 17:42:03 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2024-01-29 15:14:43 +0100
commit904f1d3b13f5893ea63781b44857ee5cef48883d (patch)
tree70e92e1cf7f9477f239bced63b656d1d0015ae99 /tests/auto/corelib/text/qlocale
parente657c31e332571ed9c717764423da378321ee374 (diff)
tst_QLocale: add some basic endonym tests
Actually triggered by investigating QTBUG-121485, where the issue turns out to be at construction time, but the complete lack of any testing of endonyms clearly needed addressed in any case. In the process, break up the long list of private slots in the test-class declaration. Task-number: QTBUG-121485 Change-Id: I49021f78d3bea2e1e55b2755a45943ab3fc23722 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/text/qlocale')
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index ac86b0c7d3..ad843a4f0a 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -67,6 +67,7 @@ private slots:
void fpExceptions();
void negativeZero_data();
void negativeZero();
+
void dayOfWeek();
void dayOfWeek_data();
void formatDate();
@@ -82,6 +83,7 @@ private slots:
void toDate();
void toTime_data();
void toTime();
+
void doubleRoundTrip_data();
void doubleRoundTrip();
void integerRoundTrip_data();
@@ -106,6 +108,8 @@ private slots:
void scriptToString();
void territoryToString_data();
void territoryToString();
+ void endonym_data();
+ void endonym();
void defaultNumberingSystem_data();
void defaultNumberingSystem();
@@ -3499,6 +3503,37 @@ void tst_QLocale::territoryToString()
QCOMPARE(QLocale::territoryToString(territory), name);
}
+void tst_QLocale::endonym_data()
+{
+ QTest::addColumn<QLocale>("locale");
+ QTest::addColumn<QString>("language");
+ QTest::addColumn<QString>("territory");
+
+ QTest::newRow("en")
+ << QLocale(QLocale::English, QLocale::UnitedStates)
+ << u"American English"_s << u"United States"_s;
+ QTest::newRow("en_GB")
+ << QLocale(QLocale::English, QLocale::UnitedKingdom)
+ << u"British English"_s << u"United Kingdom"_s; // So inaccurate
+}
+
+void tst_QLocale::endonym()
+{
+ QFETCH(const QLocale, locale);
+
+ auto report = qScopeGuard([locale]() {
+ qDebug()
+ << "Failed for" << locale.name()
+ << "with language" << QLocale::languageToString(locale.language())
+ << "for territory" << QLocale::territoryToString(locale.territory())
+ << "in script" << QLocale::scriptToString(locale.script());
+ });
+
+ QTEST(locale.nativeLanguageName(), "language");
+ QTEST(locale.nativeTerritoryName(), "territory");
+ report.dismiss();
+}
+
void tst_QLocale::currency()
{
const QLocale c(QLocale::C);