summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 126bc08903..ad59025dfe 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -458,6 +458,8 @@ private slots:
void simplified_data();
void simplified();
void trimmed();
+ void unicodeTableAccess_data();
+ void unicodeTableAccess();
void toUpper();
void toLower();
void isLower_isUpper_data();
@@ -1949,6 +1951,32 @@ void tst_QString::rightJustified()
QCOMPARE(a, QLatin1String("ABC"));
}
+void tst_QString::unicodeTableAccess_data()
+{
+ QTest::addColumn<QString>("invalid");
+
+ const auto join = [](char16_t high, char16_t low) {
+ const QChar pair[2] = { high, low };
+ return QString(pair, 2);
+ };
+ // Least high surrogate for which an invalid successor produces an error:
+ QTest::newRow("least-high") << join(0xdbf8, 0xfc00);
+ // Least successor that, after a high surrogate, produces invalid:
+ QTest::newRow("least-follow") << join(0xdbff, 0xe000);
+}
+
+void tst_QString::unicodeTableAccess()
+{
+ // QString processing must not access unicode tables out of bounds.
+ QFETCH(QString, invalid);
+ // Exercise methods, to see if any assertions trigger:
+ const auto upper = invalid.toUpper();
+ const auto lower = invalid.toLower();
+ const auto folded = invalid.toCaseFolded();
+ // Fatuous test, just to use those.
+ QVERIFY(upper == invalid || lower == invalid || folded == invalid || lower != upper);
+}
+
void tst_QString::toUpper()
{
QCOMPARE( QString().toUpper(), QString() );