Skip to content

Commit

Permalink
Add test for QLocale::bcp47Name()
Browse files Browse the repository at this point in the history
Task-number: QTBUG-61949
Change-Id: I34fece0441afb1e69ea84ae59b90c5e2b7cf133f
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
valdmann committed Jul 26, 2017
1 parent 28d1d19 commit 2031196
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ private slots:
void textDirection_data();
void textDirection();

void bcp47Name();

private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
QString m_sysapp;
Expand Down Expand Up @@ -2525,5 +2527,26 @@ void tst_QLocale::textDirection()
QCOMPARE(locale.textDirection() == Qt::RightToLeft, rightToLeft);
}

void tst_QLocale::bcp47Name()
{
QCOMPARE(QLocale("C").bcp47Name(), QStringLiteral("C"));
QCOMPARE(QLocale("en").bcp47Name(), QStringLiteral("en"));
QCOMPARE(QLocale("en_US").bcp47Name(), QStringLiteral("en"));
QCOMPARE(QLocale("en_GB").bcp47Name(), QStringLiteral("en-GB"));
QCOMPARE(QLocale("en_DE").bcp47Name(), QStringLiteral("en-DE"));
QCOMPARE(QLocale("de_DE").bcp47Name(), QStringLiteral("de"));
QCOMPARE(QLocale("sr_RS").bcp47Name(), QStringLiteral("sr"));
QCOMPARE(QLocale("sr_Cyrl_RS").bcp47Name(), QStringLiteral("sr"));
QCOMPARE(QLocale("sr_Latn_RS").bcp47Name(), QStringLiteral("sr-Latn"));
QCOMPARE(QLocale("sr_ME").bcp47Name(), QStringLiteral("sr-ME"));
QCOMPARE(QLocale("sr_Cyrl_ME").bcp47Name(), QStringLiteral("sr-Cyrl-ME"));
QCOMPARE(QLocale("sr_Latn_ME").bcp47Name(), QStringLiteral("sr-ME"));

// Fall back to defaults when country isn't in CLDR for this language:
QCOMPARE(QLocale("sr_HR").bcp47Name(), QStringLiteral("sr"));
QCOMPARE(QLocale("sr_Cyrl_HR").bcp47Name(), QStringLiteral("sr"));
QCOMPARE(QLocale("sr_Latn_HR").bcp47Name(), QStringLiteral("sr-Latn"));
}

QTEST_MAIN(tst_QLocale)
#include "tst_qlocale.moc"

0 comments on commit 2031196

Please sign in to comment.