diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2020-09-21 14:31:56 +0200 |
---|---|---|
committer | Andreas Buhr <andreas.buhr@qt.io> | 2020-09-23 16:59:07 +0200 |
commit | b50e81b5b189c98244bdc0d5081a90cd875982d0 (patch) | |
tree | a7b0281cd76ecf0b507260e2b2438e41b328ed5c /tests/auto/corelib/text | |
parent | ac0be4d568f2961556a6a07fffc3425ea4adb7db (diff) |
Add unit test to check emoji handling in date-time parsing
Add some unit tests using emojis as separator characters to check
utf handling.
Change-Id: I03c4bb5cd349e649c58e8a908c38a0185d80e722
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/corelib/text')
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index f2e4dc0ea9..7d4cbbbcdd 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1545,6 +1545,11 @@ void tst_QLocale::formatDate_data() << QDate(1974, 12, 1) << "hh:mm:ss.zzz ap d'd'dd/M/yy" << "hh:mm:ss.zzz ap 1d01/12/74"; QTest::newRow("dd MMMM yyyy") << QDate(1, 1, 1) << "dd MMMM yyyy" << "01 January 0001"; + + // Test unicode handling. + QTest::newRow("unicode in format string") << QDate(1, 1, 1) + << u8"π΄π€πΌπ«ddβπ₯π€€ππMMππππ€©yyyyπ΄" + << u8"π΄π€πΌπ«01βπ₯π€€ππ01ππππ€©0001π΄"; } void tst_QLocale::formatDate() @@ -1601,6 +1606,10 @@ void tst_QLocale::formatTime_data() QTest::newRow("33") << QTime(1, 2, 3, 4) << "H:m:s.zzz" << "1:2:3.004"; QTest::newRow("34") << QTime() << "H:m:s.zzz" << ""; QTest::newRow("35") << QTime(1, 2, 3, 4) << "dd MM yyyy H:m:s.zzz" << "dd MM yyyy 1:2:3.004"; + + // Test unicode handling. + QTest::newRow("emoji in format string") + << QTime(17, 22, 05, 18) << u8"mπssπ’H.zzz" << u8"22π05π’17.018"; } void tst_QLocale::formatTime() @@ -1762,6 +1771,11 @@ void tst_QLocale::formatDateTime_data() << QString("MMM") << QString("Dec"); QTest::newRow("empty") << "en_US" << testZeroHour << QString("") << QString(""); + + // Test unicode handling. + QTest::newRow("emoji in format string") + << "en_US" << QDateTime(QDate(1980, 2, 1), QTime(17, 12)) + << QString(u8"πyyyyπMMπdd hhπmm") << u8"π1980π02π01 17π12"; } void tst_QLocale::formatDateTime() @@ -1905,6 +1919,14 @@ void tst_QLocale::toDateTime_data() QTest::newRow("C:narrow") << "C" << dt << "d MMM yyyy HH:mm:ss" << "25 Feb 2017 17:21:25" << true; + // Test the same again with unicode and emoji. + QTest::newRow("C:long with emoji") << "C" << dt << u8"dddd, dπͺMMMM yyyy HH:mm:ss" + << u8"Saturday, 25πͺFebruary 2017 17:21:25" << true; + QTest::newRow("C:short with emoji") + << "C" << dt << u8"d MMM yyyy HHπmmπss" << u8"25 Feb 2017 17π21π25" << true; + QTest::newRow("C:narrow with emoji") + << "C" << dt << u8"π¬π§d MMM yyyy HH:mm:ssπ¬π§" << u8"π¬π§25 Feb 2017 17:21:25π¬π§" << true; + QTest::newRow("fr:long") << "fr" << dt << "dddd d MMMM yyyy HH:mm:ss" << "Samedi 25 fΓ©vrier 2017 17:21:25" << true; QTest::newRow("fr:short") |