diff options
Diffstat (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 70ccc72630..90cd70f43e 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -249,7 +249,7 @@ class CharStarContainer { const char *str; public: - explicit Q_DECL_CONSTEXPR CharStarContainer(const char *s = Q_NULLPTR) : str(s) {} + explicit Q_DECL_CONSTEXPR CharStarContainer(const char *s = nullptr) : str(s) {} Q_DECL_CONSTEXPR operator const char *() const { return str; } }; @@ -1483,7 +1483,7 @@ void tst_QString::indexOf() QRegularExpression re(QRegularExpression::escape(needle), options); QCOMPARE( haystack.indexOf(re, startpos), resultpos ); - QCOMPARE(haystack.indexOf(re, startpos, Q_NULLPTR), resultpos); + QCOMPARE(haystack.indexOf(re, startpos, nullptr), resultpos); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); @@ -1608,7 +1608,7 @@ void tst_QString::indexOfInvalidRegex() QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\")), -1); QTest::ignoreMessage(QtWarningMsg, "QString::indexOf: invalid QRegularExpression object"); - QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1); + QCOMPARE(QString("invalid regex\\").indexOf(QRegularExpression("invalid regex\\"), -1, nullptr), -1); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); @@ -1706,7 +1706,7 @@ void tst_QString::lastIndexOf() QRegularExpression re(QRegularExpression::escape(needle), options); QCOMPARE(haystack.lastIndexOf(re, from), expected); - QCOMPARE(haystack.lastIndexOf(re, from, Q_NULLPTR), expected); + QCOMPARE(haystack.lastIndexOf(re, from, nullptr), expected); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); QCOMPARE(haystack.lastIndexOf(re, from, &match), expected); @@ -1743,7 +1743,7 @@ void tst_QString::lastIndexOfInvalidRegex() QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), 0), -1); QTest::ignoreMessage(QtWarningMsg, "QString::lastIndexOf: invalid QRegularExpression object"); - QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, Q_NULLPTR), -1); + QCOMPARE(QString("invalid regex\\").lastIndexOf(QRegularExpression("invalid regex\\"), -1, nullptr), -1); QRegularExpressionMatch match; QVERIFY(!match.hasMatch()); @@ -2994,6 +2994,12 @@ void tst_QString::remove_string() QString s5 = string; s5.replace( QRegExp(before, cs, QRegExp::FixedString), after ); QTEST( s5, "result" ); + + if (QtPrivate::isLatin1(before)) { + QString s6 = string; + s6.remove( QLatin1String(before.toLatin1()), cs ); + QTEST( s6, "result" ); + } } else { QCOMPARE( 0, 0 ); // shut Qt Test } @@ -6901,6 +6907,25 @@ void tst_QString::isRightToLeft_data() static const ushort unicode3[] = { QChar::highSurrogate(0x10800u), QChar::lowSurrogate(0x10800u), QChar::highSurrogate(0x10805u), QChar::lowSurrogate(0x10805u) }; QTest::newRow("surrogates-cypriot") << QString::fromUtf16(unicode3, 4) << true; + + QTest::newRow("lre") << (QString("12345") + QChar(0x202a) + QString("9") + QChar(0x202c)) << false; + QTest::newRow("rle") << (QString("12345") + QChar(0x202b) + QString("9") + QChar(0x202c)) << false; + QTest::newRow("r in lre") << (QString("12345") + QChar(0x202a) + QString::fromUtf16(unicode1, 2) + QChar(0x202c) + QString("a")) << true; + QTest::newRow("l in lre") << (QString("12345") + QChar(0x202a) + QString("a") + QChar(0x202c) + QString::fromUtf16(unicode1, 2)) << false; + QTest::newRow("r in rle") << (QString("12345") + QChar(0x202b) + QString::fromUtf16(unicode1, 2) + QChar(0x202c) + QString("a")) << true; + QTest::newRow("l in rle") << (QString("12345") + QChar(0x202b) + QString("a") + QChar(0x202c) + QString::fromUtf16(unicode1, 2)) << false; + + QTest::newRow("lro") << (QString("12345") + QChar(0x202d) + QString("9") + QChar(0x202c)) << false; + QTest::newRow("rlo") << (QString("12345") + QChar(0x202e) + QString("9") + QChar(0x202c)) << false; + QTest::newRow("r in lro") << (QString("12345") + QChar(0x202d) + QString::fromUtf16(unicode1, 2) + QChar(0x202c) + QString("a")) << true; + QTest::newRow("l in lro") << (QString("12345") + QChar(0x202d) + QString("a") + QChar(0x202c) + QString::fromUtf16(unicode1, 2)) << false; + QTest::newRow("r in rlo") << (QString("12345") + QChar(0x202e) + QString::fromUtf16(unicode1, 2) + QChar(0x202c) + QString("a")) << true; + QTest::newRow("l in rlo") << (QString("12345") + QChar(0x202e) + QString("a") + QChar(0x202c) + QString::fromUtf16(unicode1, 2)) << false; + + QTest::newRow("lri") << (QString("12345") + QChar(0x2066) + QString("a") + QChar(0x2069) + QString::fromUtf16(unicode1, 2)) << true; + QTest::newRow("rli") << (QString("12345") + QChar(0x2067) + QString::fromUtf16(unicode1, 2) + QChar(0x2069) + QString("a")) << false; + QTest::newRow("fsi1") << (QString("12345") + QChar(0x2068) + QString("a") + QChar(0x2069) + QString::fromUtf16(unicode1, 2)) << true; + QTest::newRow("fsi2") << (QString("12345") + QChar(0x2068) + QString::fromUtf16(unicode1, 2) + QChar(0x2069) + QString("a")) << false; } void tst_QString::isRightToLeft() |