diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-04 15:19:26 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-15 14:41:05 +0100 |
commit | 1869615fc959c70a334e666ebf95ff595a3d6e67 (patch) | |
tree | b3940f0c18afcabd3c531f172b040a47d34c55d0 /tests/auto/corelib/text | |
parent | 1aec96bffdce7e835aa33f01f44269594a955548 (diff) |
QChar: make construction from integral explicit
QChar should not be convertible from any integral type except from
char16_t, short and possibly char (since it's a direct superset).
David provided the perfect example:
if (str == 123) { ~~~ }
compiles, with 123 implicitly converted to QChar (str == "123"
was meant instead). But similarly one can construct other
scenarios where QString(123) gets accidentally used (instead of
QString::number(123)), like QString s; s += 123;.
Add a macro to revert to the implicit constructors, for backwards
compatibility.
The breaks are mostly in tests that "abuse" of integers (arithmetic,
etc.). Maybe it's time for user-defined literals for QChar/QString,
but that is left for another commit.
[ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar
constructors from integral types are now by default explicit.
It is recommended to use explicit conversions, QLatin1Char,
QChar::fromUcs4 instead of implicit conversions. The old behavior
can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION
macro.
Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/corelib/text')
5 files changed, 76 insertions, 66 deletions
diff --git a/tests/auto/corelib/text/qchar/tst_qchar.cpp b/tests/auto/corelib/text/qchar/tst_qchar.cpp index b150600e36..134862f716 100644 --- a/tests/auto/corelib/text/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/text/qchar/tst_qchar.cpp @@ -115,9 +115,9 @@ void tst_QChar::fromUcs4() void tst_QChar::fromWchar_t() { #if defined(Q_OS_WIN) - QChar aUmlaut = L'\u00E4'; // German small letter a-umlaut + QChar aUmlaut(L'\u00E4'); // German small letter a-umlaut QCOMPARE(aUmlaut, QChar(0xE4)); - QChar replacementCharacter = L'\uFFFD'; + QChar replacementCharacter(L'\uFFFD'); QCOMPARE(replacementCharacter, QChar(QChar::ReplacementCharacter)); #else QSKIP("This is a Windows-only test."); diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 29d794490b..99f42e2815 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -3991,7 +3991,7 @@ void tst_QString::check_QTextIOStream() void tst_QString::fromRawData() { - const QChar ptr[] = { 0x1234, 0x0000 }; + const QChar ptr[] = { QChar(0x1234), QChar(0x0000) }; QString cstr = QString::fromRawData(ptr, 1); QVERIFY(!cstr.isDetached()); QVERIFY(cstr.constData() == ptr); @@ -4008,8 +4008,8 @@ void tst_QString::fromRawData() void tst_QString::setRawData() { - const QChar ptr[] = { 0x1234, 0x0000 }; - const QChar ptr2[] = { 0x4321, 0x0000 }; + const QChar ptr[] = { QChar(0x1234), QChar(0x0000) }; + const QChar ptr2[] = { QChar(0x4321), QChar(0x0000) }; QString cstr; // This just tests the fromRawData() fallback @@ -4278,7 +4278,7 @@ void tst_QString::invalidToLocal8Bit_data() QTest::addColumn<QByteArray>("expect"); // Initial validly-converted prefix { - const QChar malformed[] = { 'A', 0xd800, 'B', 0 }; + const QChar malformed[] = { 'A', QChar(0xd800), 'B', '\0' }; const char expected[] = "A"; QTest::newRow("LoneHighSurrogate") << QString(malformed, sizeof(malformed) / sizeof(QChar)) @@ -4286,28 +4286,28 @@ void tst_QString::invalidToLocal8Bit_data() << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); } { - const QChar malformed[] = { 'A', 0xdc00, 'B', 0 }; + const QChar malformed[] = { 'A', QChar(0xdc00), 'B', '\0' }; const char expected[] = "A"; QTest::newRow("LoneLowSurrogate") << QString(malformed, sizeof(malformed) / sizeof(QChar)) << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); } { - const QChar malformed[] = { 'A', 0xd800, 0xd801, 'B', 0 }; + const QChar malformed[] = { 'A', QChar(0xd800), QChar(0xd801), 'B', '\0' }; const char expected[] = "A"; QTest::newRow("DoubleHighSurrogate") << QString(malformed, sizeof(malformed) / sizeof(QChar)) << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); } { - const QChar malformed[] = { 'A', 0xdc00, 0xdc01, 'B', 0 }; + const QChar malformed[] = { 'A', QChar(0xdc00), QChar(0xdc01), 'B', '\0' }; const char expected[] = "A"; QTest::newRow("DoubleLowSurrogate") << QString(malformed, sizeof(malformed) / sizeof(QChar)) << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); } { - const QChar malformed[] = { 'A', 0xdc00, 0xd800, 'B', 0 }; + const QChar malformed[] = { 'A', QChar(0xdc00), QChar(0xd800), 'B', '\0' }; const char expected[] = "A"; QTest::newRow("ReversedSurrogates") // low before high << QString(malformed, sizeof(malformed) / sizeof(QChar)) diff --git a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp index c3ad151a51..a457744867 100644 --- a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp +++ b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp @@ -610,7 +610,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1-1") << utf8 << str << -1; // 3.3.2 @@ -620,7 +620,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-1") << utf8 << str << -1; utf8.clear(); @@ -628,7 +628,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-2") << utf8 << str << -1; utf8 += 0x30; - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-3") << utf8 << str << -1; // 3.3.3 @@ -639,7 +639,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-1") << utf8 << str << -1; utf8.clear(); @@ -647,7 +647,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-3") << utf8 << str << -1; utf8.clear(); @@ -656,7 +656,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-5") << utf8 << str << -1; // 3.3.4 @@ -668,7 +668,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-1") << utf8 << str << -1; utf8.clear(); @@ -678,7 +678,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-3") << utf8 << str << -1; utf8.clear(); @@ -687,7 +687,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-5") << utf8 << str << -1; utf8.clear(); @@ -695,7 +695,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-6") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-7") << utf8 << str << -1; // 3.3.5 @@ -708,7 +708,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-1") << utf8 << str << -1; utf8.clear(); @@ -719,7 +719,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-3") << utf8 << str << -1; utf8.clear(); @@ -729,7 +729,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-5") << utf8 << str << -1; utf8.clear(); @@ -738,7 +738,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-6") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-7") << utf8 << str << -1; utf8.clear(); @@ -746,7 +746,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-8") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-9") << utf8 << str << -1; // 3.3.6 @@ -755,7 +755,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6-1") << utf8 << str << -1; // 3.3.7 @@ -765,7 +765,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-1") << utf8 << str << -1; utf8.clear(); @@ -773,7 +773,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-3") << utf8 << str << -1; // 3.3.8 @@ -784,7 +784,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-1") << utf8 << str << -1; utf8.clear(); @@ -793,7 +793,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-3") << utf8 << str << -1; utf8.clear(); @@ -801,7 +801,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-5") << utf8 << str << -1; // 3.3.9 @@ -813,7 +813,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-1") << utf8 << str << -1; utf8.clear(); @@ -823,7 +823,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-3") << utf8 << str << -1; utf8.clear(); @@ -832,7 +832,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-5") << utf8 << str << -1; utf8.clear(); @@ -840,7 +840,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-6") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-7") << utf8 << str << -1; // 3.3.10 @@ -853,7 +853,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-1") << utf8 << str << -1; utf8.clear(); @@ -864,7 +864,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-2") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-3") << utf8 << str << -1; utf8.clear(); @@ -874,7 +874,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-4") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-5") << utf8 << str << -1; utf8.clear(); @@ -883,7 +883,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-6") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-7") << utf8 << str << -1; utf8.clear(); @@ -891,7 +891,7 @@ void tst_QStringConverter::utf8Codec_data() str = fromInvalidUtf8Sequence(utf8); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-8") << utf8 << str << -1; utf8 += char(0x30); - str += 0x30; + str += QChar(0x30); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-9") << utf8 << str << -1; // 3.4 diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index 4cff432a2d..42b4767c50 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -666,7 +666,7 @@ template <typename Char> void tst_QStringView::fromLiteral(const Char *arg) const { const Char *null = nullptr; - const Char empty[] = { 0 }; + const Char empty[] = { Char{} }; QCOMPARE(QStringView(null).size(), qsizetype(0)); QCOMPARE(QStringView(null).data(), nullptr); diff --git a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 9c212a6a0b..bd9d91580d 100644 --- a/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/text/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -293,7 +293,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() QTest::addColumn<QList<int> >("expectedEndPositions"); { - QChar s[] = { 0x000D, 0x000A, 0x000A }; + QChar s[] = { QChar(0x000D), QChar(0x000A), QChar(0x000A) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 2 << 3; @@ -302,7 +302,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x000D, 0x0308, 0x000A, 0x000A }; + QChar s[] = { QChar(0x000D), QChar(0x0308), QChar(0x000A), QChar(0x000A) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 2 << 3 << 4; @@ -366,7 +366,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() // Sample Strings from WordBreakTest.html { - QChar s[] = { 0x0063, 0x0061, 0x006E, 0x0027, 0x0074 }; + QChar s[] = { QChar(0x0063), QChar(0x0061), QChar(0x006E), QChar(0x0027), QChar(0x0074) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 5; @@ -377,7 +377,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x0063, 0x0061, 0x006E, 0x2019, 0x0074 }; + QChar s[] = { QChar(0x0063), QChar(0x0061), QChar(0x006E), QChar(0x2019), QChar(0x0074) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 5; @@ -388,7 +388,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x0061, 0x0062, 0x00AD, 0x0062, 0x0061 }; + QChar s[] = { QChar(0x0061), QChar(0x0062), QChar(0x00AD), QChar(0x0062), QChar(0x0061) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 5; @@ -399,8 +399,10 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x0061, 0x0024, 0x002D, 0x0033, 0x0034, 0x002C, 0x0035, 0x0036, - 0x0037, 0x002E, 0x0031, 0x0034, 0x0025, 0x0062 }; + QChar s[] = { QChar(0x0061), QChar(0x0024), QChar(0x002D), QChar(0x0033), + QChar(0x0034), QChar(0x002C), QChar(0x0035), QChar(0x0036), + QChar(0x0037), QChar(0x002E), QChar(0x0031), QChar(0x0034), + QChar(0x0025), QChar(0x0062) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 2 << 3 << 12 << 13 << 14; @@ -411,7 +413,7 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x0033, 0x0061 }; + QChar s[] = { QChar(0x0033), QChar(0x0061) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 2; @@ -422,8 +424,9 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x2060, 0x0063, 0x2060, 0x0061, 0x2060, 0x006E, 0x2060, 0x0027, - 0x2060, 0x0074, 0x2060, 0x2060 }; + QChar s[] = { QChar(0x2060), QChar(0x0063), QChar(0x2060), QChar(0x0061), + QChar(0x2060), QChar(0x006E), QChar(0x2060), QChar(0x0027), + QChar(0x2060), QChar(0x0074), QChar(0x2060), QChar(0x2060) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 12; @@ -434,8 +437,9 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x2060, 0x0063, 0x2060, 0x0061, 0x2060, 0x006E, 0x2060, 0x2019, - 0x2060, 0x0074, 0x2060, 0x2060 }; + QChar s[] = { QChar(0x2060), QChar(0x0063), QChar(0x2060), QChar(0x0061), + QChar(0x2060), QChar(0x006E), QChar(0x2060), QChar(0x2019), + QChar(0x2060), QChar(0x0074), QChar(0x2060), QChar(0x2060) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 12; @@ -446,8 +450,9 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x2060, 0x0061, 0x2060, 0x0062, 0x2060, 0x00AD, 0x2060, 0x0062, - 0x2060, 0x0061, 0x2060, 0x2060 }; + QChar s[] = { QChar(0x2060), QChar(0x0061), QChar(0x2060), QChar(0x0062), + QChar(0x2060), QChar(0x00AD), QChar(0x2060), QChar(0x0062), + QChar(0x2060), QChar(0x0061), QChar(0x2060), QChar(0x2060) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 12; @@ -458,10 +463,14 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x2060, 0x0061, 0x2060, 0x0024, 0x2060, 0x002D, 0x2060, 0x0033, - 0x2060, 0x0034, 0x2060, 0x002C, 0x2060, 0x0035, 0x2060, 0x0036, - 0x2060, 0x0037, 0x2060, 0x002E, 0x2060, 0x0031, 0x2060, 0x0034, - 0x2060, 0x0025, 0x2060, 0x0062, 0x2060, 0x2060 }; + QChar s[] = { QChar(0x2060), QChar(0x0061), QChar(0x2060), QChar(0x0024), + QChar(0x2060), QChar(0x002D), QChar(0x2060), QChar(0x0033), + QChar(0x2060), QChar(0x0034), QChar(0x2060), QChar(0x002C), + QChar(0x2060), QChar(0x0035), QChar(0x2060), QChar(0x0036), + QChar(0x2060), QChar(0x0037), QChar(0x2060), QChar(0x002E), + QChar(0x2060), QChar(0x0031), QChar(0x2060), QChar(0x0034), + QChar(0x2060), QChar(0x0025), QChar(0x2060), QChar(0x0062), + QChar(0x2060), QChar(0x2060) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 3 << 5 << 7 << 25 << 27 << 30; @@ -472,7 +481,8 @@ void tst_QTextBoundaryFinder::wordBoundaries_manual_data() << expectedStartPositions << expectedEndPositions; } { - QChar s[] = { 0x2060, 0x0033, 0x2060, 0x0061, 0x2060, 0x2060 }; + QChar s[] = { QChar(0x2060), QChar(0x0033), QChar(0x2060), QChar(0x0061), + QChar(0x2060), QChar(0x2060) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedStartPositions, expectedEndPositions; expectedBreakPositions << 0 << 1 << 6; @@ -502,7 +512,7 @@ void tst_QTextBoundaryFinder::sentenceBoundaries_manual_data() QTest::addColumn<QList<int> >("expectedBreakPositions"); { - QChar s[] = { 0x000D, 0x000A, 0x000A }; + QChar s[] = { QChar(0x000D), QChar(0x000A), QChar(0x000A) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions; expectedBreakPositions << 0 << 2 << 3; @@ -510,7 +520,7 @@ void tst_QTextBoundaryFinder::sentenceBoundaries_manual_data() QTest::newRow("+CRxLF+LF+") << testString << expectedBreakPositions; } { - QChar s[] = { 0x000D, 0x0308, 0x000A, 0x000A }; + QChar s[] = { QChar(0x000D), QChar(0x0308), QChar(0x000A), QChar(0x000A) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions; expectedBreakPositions << 0 << 1 << 3 << 4; @@ -587,7 +597,7 @@ void tst_QTextBoundaryFinder::lineBoundaries_manual_data() } { - QChar s[] = { 0x000D, 0x0308, 0x000A, 0x000A, 0x0020 }; + QChar s[] = { QChar(0x000D), QChar(0x0308), QChar(0x000A), QChar(0x000A), QChar(0x0020) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedMandatoryBreakPositions; expectedBreakPositions << 0 << 1 << 3 << 4 << 5; @@ -597,7 +607,7 @@ void tst_QTextBoundaryFinder::lineBoundaries_manual_data() << expectedMandatoryBreakPositions; } { - QChar s[] = { 0x000A, 0x2E80, 0x0308, 0x0023, 0x0023 }; + QChar s[] = { QChar(0x000A), QChar(0x2E80), QChar(0x0308), QChar(0x0023), QChar(0x0023) }; QString testString(s, sizeof(s)/sizeof(QChar)); QList<int> expectedBreakPositions, expectedMandatoryBreakPositions; expectedBreakPositions << 0 << 1 << 3 << 5; @@ -607,7 +617,7 @@ void tst_QTextBoundaryFinder::lineBoundaries_manual_data() << expectedMandatoryBreakPositions; } { - QChar s[] = { 0x000A, 0x0308, 0x0023, 0x0023 }; + QChar s[] = { QChar(0x000A), QChar(0x0308), QChar(0x0023), QChar(0x0023) }; QString testString(s, sizeof(s)/sizeof(QChar)); QList<int> expectedBreakPositions, expectedMandatoryBreakPositions; expectedBreakPositions << 0 << 1 << 4; @@ -618,7 +628,7 @@ void tst_QTextBoundaryFinder::lineBoundaries_manual_data() } { - QChar s[] = { 0x0061, 0x00AD, 0x0062, 0x0009, 0x0063, 0x0064 }; + QChar s[] = { QChar(0x0061), QChar(0x00AD), QChar(0x0062), QChar(0x0009), QChar(0x0063), QChar(0x0064) }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions, expectedMandatoryBreakPositions; expectedBreakPositions << 0 << 2 << 4 << 6; |