diff options
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qchar/tst_qchar.cpp | 42 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlocale/test/test.pro | 1 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp | 111 |
3 files changed, 144 insertions, 10 deletions
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index e72af11fbb..14c43d0088 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -77,6 +77,7 @@ private slots: void joining(); void combiningClass(); void digitValue(); + void mirroredChar(); void decomposition(); void lineBreakClass(); void normalization_data(); @@ -523,6 +524,29 @@ void tst_QChar::digitValue() QVERIFY(QChar::digitValue((ushort)0x1040) == 0); QVERIFY(QChar::digitValue((uint)0x1049) == 9); QVERIFY(QChar::digitValue((uint)0x1040) == 0); + + QVERIFY(QChar::digitValue((ushort)0xd800) == -1); + QVERIFY(QChar::digitValue((uint)UNICODE_LAST_CODEPOINT + 1) == -1); +} + +void tst_QChar::mirroredChar() +{ + QVERIFY(QChar(0x169B).hasMirrored()); + QVERIFY(QChar(0x169B).mirroredChar() == QChar(0x169C)); + QVERIFY(QChar(0x169C).hasMirrored()); + QVERIFY(QChar(0x169C).mirroredChar() == QChar(0x169B)); + + QVERIFY(QChar(0x301A).hasMirrored()); + QVERIFY(QChar(0x301A).mirroredChar() == QChar(0x301B)); + QVERIFY(QChar(0x301B).hasMirrored()); + QVERIFY(QChar(0x301B).mirroredChar() == QChar(0x301A)); + + if (QChar::currentUnicodeVersion() <= QChar::Unicode_5_0) { + QVERIFY(!QChar(0x201C).hasMirrored()); + QVERIFY(QChar(0x201C).mirroredChar() != QChar(0x201D)); + QVERIFY(!QChar(0x201D).hasMirrored()); + QVERIFY(QChar(0x201D).mirroredChar() != QChar(0x201C)); + } } void tst_QChar::decomposition() @@ -540,10 +564,10 @@ void tst_QChar::decomposition() { QString str; - str += QChar( (0x1D157 - 0x10000) / 0x400 + 0xd800 ); - str += QChar( ((0x1D157 - 0x10000) % 0x400) + 0xdc00 ); - str += QChar( (0x1D165 - 0x10000) / 0x400 + 0xd800 ); - str += QChar( ((0x1D165 - 0x10000) % 0x400) + 0xdc00 ); + str += QChar(QChar::highSurrogate(0x1D157)); + str += QChar(QChar::lowSurrogate(0x1D157)); + str += QChar(QChar::highSurrogate(0x1D165)); + str += QChar(QChar::lowSurrogate(0x1D165)); QVERIFY(QChar::decomposition(0x1D15e) == str); } @@ -626,14 +650,12 @@ void tst_QChar::normalization_data() for (int j = 0; j < c.size(); ++j) { bool ok; uint uc = c.at(j).toInt(&ok, 16); - if (uc < 0x10000) + if (!QChar::requiresSurrogates(uc)) { columns[i].append(QChar(uc)); - else { + } else { // convert to utf16 - ushort high = QChar::highSurrogate(uc); - ushort low = QChar::lowSurrogate(uc); - columns[i].append(QChar(high)); - columns[i].append(QChar(low)); + columns[i].append(QChar(QChar::highSurrogate(uc))); + columns[i].append(QChar(QChar::lowSurrogate(uc))); } } } diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 24dcc0638a..28e127e307 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -17,3 +17,4 @@ load(testcase) # for target.path and installTestHelperApp() installTestHelperApp("../syslocaleapp/syslocaleapp",syslocaleapp,syslocaleapp) mac: CONFIG += insignificant_test # QTBUG-22769 +win32:CONFIG+= insignificant_test # QTBUG-25284 diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index a4c04d6207..f1de1722e2 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -637,6 +637,52 @@ void tst_QRegularExpression::normalMatch_data() << 0 << QRegularExpression::MatchOptions(QRegularExpression::AnchoredMatchOption) << m; + + // *** + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "678"; + QTest::newRow("negativeoffset01") << QRegularExpression("\\d+") + << "abc123def678ghi" + << -6 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "678"; + QTest::newRow("negativeoffset02") << QRegularExpression("\\d+") + << "abc123def678ghi" + << -8 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "678ghi" << "678" << "ghi"; + QTest::newRow("negativeoffset03") << QRegularExpression("(\\d+)(\\w+)") + << "abc123def678ghi" + << -8 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("negativeoffset04") << QRegularExpression("\\d+") + << "abc123def678ghi" + << -3 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "678"; + QTest::newRow("negativeoffset05") << QRegularExpression("^\\d+", QRegularExpression::MultilineOption) + << "a\nbc123\ndef\n678gh\ni" + << -10 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; } @@ -959,6 +1005,31 @@ void tst_QRegularExpression::globalMatch_data() matchList.clear(); m.clear(); m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "ACA""GTG""CGA""AAA"; + matchList << m; + m.captured = QStringList() << "AAA"; + matchList << m; + m.captured = QStringList() << "AAG""GAA""AAG""AAA"; + matchList << m; + m.captured = QStringList() << "AAA"; + matchList << m; + QTest::newRow("globalmatch03") << QRegularExpression("\\G(?:\\w\\w\\w)*?AAA") + << "ACA""GTG""CGA""AAA""AAA""AAG""GAA""AAG""AAA""AAA" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + QTest::newRow("globalmatch04") << QRegularExpression("(?:\\w\\w\\w)*?AAA") + << "ACA""GTG""CGA""AAA""AAA""AAG""GAA""AAG""AAA""AAA" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::AnchoredMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; m.captured = QStringList() << ""; matchList << m; m.captured = QStringList() << "c"; @@ -1103,6 +1174,46 @@ void tst_QRegularExpression::globalMatch_data() << QRegularExpression::NormalMatch << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "ABC"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "DEF"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "GHI"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + QTest::newRow("globalmatch_emptycaptures07") << QRegularExpression("[\\x{0000}-\\x{FFFF}]*") + << QString::fromUtf8("ABC""\xf0\x9d\x85\x9d""DEF""\xf0\x9d\x85\x9e""GHI") + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << QString::fromUtf8("ABC""\xc3\x80"); + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << QString::fromUtf8("\xc3\x80""DEF""\xc3\x80"); + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + QTest::newRow("globalmatch_emptycaptures08") << QRegularExpression("[\\x{0000}-\\x{FFFF}]*") + << QString::fromUtf8("ABC""\xc3\x80""\xf0\x9d\x85\x9d""\xc3\x80""DEF""\xc3\x80") + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; } void tst_QRegularExpression::globalMatch() |