Skip to content

Commit

Permalink
tst_QLocale: add some basic endonym tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
ediosyncratic committed Jan 29, 2024
1 parent e657c31 commit 904f1d3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/auto/corelib/text/qlocale/tst_qlocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private slots:
void fpExceptions();
void negativeZero_data();
void negativeZero();

void dayOfWeek();
void dayOfWeek_data();
void formatDate();
Expand All @@ -82,6 +83,7 @@ private slots:
void toDate();
void toTime_data();
void toTime();

void doubleRoundTrip_data();
void doubleRoundTrip();
void integerRoundTrip_data();
Expand All @@ -106,6 +108,8 @@ private slots:
void scriptToString();
void territoryToString_data();
void territoryToString();
void endonym_data();
void endonym();

void defaultNumberingSystem_data();
void defaultNumberingSystem();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 904f1d3

Please sign in to comment.