summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-09-21 14:31:56 +0200
committerAndreas Buhr <andreas.buhr@qt.io>2020-09-23 16:59:07 +0200
commitb50e81b5b189c98244bdc0d5081a90cd875982d0 (patch)
treea7b0281cd76ecf0b507260e2b2438e41b328ed5c /tests/auto/corelib/text
parentac0be4d568f2961556a6a07fffc3425ea4adb7db (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.cpp22
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")