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 | |
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')
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 22 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdate/tst_qdate.cpp | 6 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 5 | ||||
-rw-r--r-- | tests/auto/corelib/time/qtime/tst_qtime.cpp | 6 |
4 files changed, 39 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") diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 30917c8cfd..c133ed3c76 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1289,6 +1289,12 @@ void tst_QDate::fromStringFormat_data() QTest::newRow("data43") << QString("060521") << QString("yyMMdd") << QDate(1906,5,21); QTest::newRow("lateMarch") << QString("9999-03-06") << QString("yyyy-MM-dd") << QDate(9999, 3, 6); QTest::newRow("late") << QString("9999-12-31") << QString("yyyy-MM-dd") << QDate(9999, 12, 31); + + // Test unicode handling. + QTest::newRow("Unicode in format string") + << QString(u8"2020π€£09π€£21") << QString(u8"yyyyπ€£MMπ€£dd") << QDate(2020, 9, 21); + QTest::newRow("Unicode in quoted format string") + << QString(u8"π€£π€£2020π09π€£21") << QString(u8"'π€£π€£'yyyyπMMπ€£dd") << QDate(2020, 9, 21); } diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index c6ec869460..b942316c95 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -2673,6 +2673,11 @@ void tst_QDateTime::fromStringStringFormat_data() << QStringLiteral("2018 wilful long working block relief 12-19T21:09 cruel") << QStringLiteral("yyyy wilful long working block relief MM-ddThh:mm cruel blurb encore flux") << QDateTime(); + + // test unicode + QTest::newRow("unicode handling") << QString(u8"2005π€£06π€£28T07π€£57π€£30.001Z") + << QString(u8"yyyyπ€£MMπ€£ddThhπ€£mmπ€£ss.zt") + << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1), Qt::UTC); } void tst_QDateTime::fromStringStringFormat() diff --git a/tests/auto/corelib/time/qtime/tst_qtime.cpp b/tests/auto/corelib/time/qtime/tst_qtime.cpp index eaa90971f2..c06e7c37a4 100644 --- a/tests/auto/corelib/time/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/time/qtime/tst_qtime.cpp @@ -558,6 +558,12 @@ void tst_QTime::fromStringFormat_data() QTest::newRow("short-msecs-lt100") << QString("10:12:34:045") << QString("hh:m:ss:z") << QTime(10,12,34,45); QTest::newRow("short-msecs-gt100") << QString("10:12:34:45") << QString("hh:m:ss:z") << QTime(10,12,34,450); QTest::newRow("late") << QString("23:59:59.999") << QString("hh:mm:ss.z") << QTime(23, 59, 59, 999); + + // Test unicode handling. + QTest::newRow("emoji in format string 1") + << QString("12π31:25.05") << QString("hhπmm:ss.z") << QTime(12, 31, 25, 50); + QTest::newRow("emoji in format string 2") + << QString("π12π31π25πΊ05π") << QString("πhhπmmπssπΊzπ") << QTime(12, 31, 25, 50); } void tst_QTime::fromStringFormat() |