diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2020-05-10 17:58:59 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2020-05-12 05:43:37 +0000 |
commit | 23849826b490c07d9ba656bcb4ac46edd3040c0a (patch) | |
tree | 5a96b82fda56c54b12eb6778839172b4853c2eef /tests/auto/corelib | |
parent | b62bff2ef3a6c846462e5381664651f49944261a (diff) |
Sweep of int-ish → char-ish types near calls to QString::fromU*()
The fromUtf16(ushort*) and fromUcs4(uint*) overloads are going
to be deprecated. Use the newer fromUtf16(char16_t*) and
fromUcs4(char32_t*) overloads.
As a drive-by, use std::end()/std::size() where applicable.
Change-Id: I5a93e38cae4a2e33d49c90d06c5f14f7cb7ce90c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib')
7 files changed, 130 insertions, 130 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 78b6449a69..799c0bfc77 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -1562,24 +1562,24 @@ void tst_QTextCodec::utf8bom_data() << QString::fromLatin1("\240"); { - static const ushort data[] = { 0x201d }; + static const char16_t data[] = { 0x201d }; QTest::newRow("nobom 2") << QByteArray("\342\200\235", 3) - << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + << QString::fromUtf16(data, std::size(data)); } { - static const ushort data[] = { 0xf000 }; + static const char16_t data[] = { 0xf000 }; QTest::newRow("bom1") << QByteArray("\357\200\200", 3) - << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + << QString::fromUtf16(data, std::size(data)); } { - static const ushort data[] = { 0xfec0 }; + static const char16_t data[] = { 0xfec0 }; QTest::newRow("bom2") << QByteArray("\357\273\200", 3) - << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + << QString::fromUtf16(data, std::size(data)); } { @@ -1589,17 +1589,17 @@ void tst_QTextCodec::utf8bom_data() } { // test the non-SIMD code-path - static const ushort data[] = { 0x61, 0xfeff, 0x62 }; + static const char16_t data[] = { 0x61, 0xfeff, 0x62 }; QTest::newRow("middle-bom (non SIMD)") << QByteArray("a\357\273\277b") - << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + << QString::fromUtf16(data, std::size(data)); } { // test the SIMD code-path - static const ushort data[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0xfeff, 0x6d }; + static const char16_t data[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0xfeff, 0x6d }; QTest::newRow("middle-bom (SIMD)") << QByteArray("abcdefghijkl\357\273\277m") - << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + << QString::fromUtf16(data, std::size(data)); } } diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index 9ce1748e72..3689cb1b20 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -126,24 +126,24 @@ void tst_Utf8::roundTrip_data() QTest::newRow("utf8_4") << QByteArray(utf8_4) << QString(QChar(QChar::ReplacementCharacter)); static const char utf8_5[] = "\360\220\210\203"; // U+010203 - static const uint utf32_5[] = { 0x010203 }; + static const char32_t utf32_5[] = { 0x010203 }; QTest::newRow("utf8_5") << QByteArray(utf8_5) << QString::fromUcs4(utf32_5, 1); static const char utf8_6[] = "\364\217\277\275"; // U+10FFFD - static const uint utf32_6[] = { 0x10FFFD }; + static const char32_t utf32_6[] = { 0x10FFFD }; QTest::newRow("utf8_6") << QByteArray(utf8_6) << QString::fromUcs4(utf32_6, 1); static const char utf8_7[] = "abc\302\240\303\241\303\251\307\275 \342\202\254def"; - static const ushort utf16_7[] = { 'a', 'b', 'c', 0x00A0, - 0x00E1, 0x00E9, 0x01FD, - ' ', 0x20AC, 'd', 'e', 'f', 0 }; + static const char16_t utf16_7[] = { 'a', 'b', 'c', 0x00A0, + 0x00E1, 0x00E9, 0x01FD, + ' ', 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_7") << QByteArray(utf8_7) << QString::fromUtf16(utf16_7); static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\275 \342\202\254def"; - static const uint utf32_8[] = { 'a', 'b', 'c', 0x00A0, - 0x00E1, 0x00E9, 0x01FD, - ' ', 0x10FFFD, ' ', - 0x20AC, 'd', 'e', 'f', 0 }; + static const char32_t utf32_8[] = { 'a', 'b', 'c', 0x00A0, + 0x00E1, 0x00E9, 0x01FD, + ' ', 0x10FFFD, ' ', + 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_8") << QByteArray(utf8_8) << QString::fromUcs4(utf32_8); } diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 4260accfd0..39897f3a58 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -454,7 +454,7 @@ void tst_QDebug::qDebugQString() const QCOMPARE(s_msg, QString("\"\\U000E0001 \\U00100000\"")); // broken surrogate pairs - ushort utf16[] = { 0xDC00, 0xD800, 'x', 0xD800, 0 }; + char16_t utf16[] = { 0xDC00, 0xD800, 'x', 0xD800, 0 }; string = QString::fromUtf16(utf16); qDebug() << string; QCOMPARE(s_msg, QString("\"\\uDC00\\uD800x\\uD800\"")); diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index f644979c06..5608d2479c 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -41,18 +41,18 @@ #define STRINGPREP_BIDI_BOTH_L_AND_RAL 4 #define STRINGPREP_BIDI_LEADTRAIL_NOT_RAL 5 -struct ushortarray { - ushortarray() {} +struct char16array { + char16array() {} template <size_t N> - ushortarray(unsigned short (&array)[N]) + char16array(char16_t (&array)[N]) { - memcpy(points, array, N*sizeof(unsigned short)); + memcpy(points, array, N*sizeof(char16_t)); } - unsigned short points[100]; + char16_t points[100]; }; -Q_DECLARE_METATYPE(ushortarray) +Q_DECLARE_METATYPE(char16array) Q_DECLARE_METATYPE(QUrl::FormattingOptions) Q_DECLARE_METATYPE(QUrl::ComponentFormattingOptions) @@ -93,144 +93,144 @@ private Q_SLOTS: void tst_QUrlInternal::idna_testsuite_data() { QTest::addColumn<int>("numchars"); - QTest::addColumn<ushortarray>("unicode"); + QTest::addColumn<char16array>("unicode"); QTest::addColumn<QByteArray>("punycode"); QTest::addColumn<int>("allowunassigned"); QTest::addColumn<int>("usestd3asciirules"); QTest::addColumn<int>("toasciirc"); QTest::addColumn<int>("tounicoderc"); - unsigned short d1[] = { 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643, - 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A, - 0x061F }; - QTest::newRow("Arabic (Egyptian)") << 17 << ushortarray(d1) + char16_t d1[] = { 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643, + 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A, + 0x061F }; + QTest::newRow("Arabic (Egyptian)") << 17 << char16array(d1) << QByteArray(IDNA_ACE_PREFIX "egbpdaj6bu4bxfgehfvwxn") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d2[] = { 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D, - 0x6587 }; - QTest::newRow("Chinese (simplified)") << 9 << ushortarray(d2) + char16_t d2[] = { 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D, + 0x6587 }; + QTest::newRow("Chinese (simplified)") << 9 << char16array(d2) << QByteArray(IDNA_ACE_PREFIX "ihqwcrb4cv8a8dqg056pqjye") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d3[] = { 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D, - 0x6587 }; - QTest::newRow("Chinese (traditional)") << 9 << ushortarray(d3) + char16_t d3[] = { 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D, + 0x6587 }; + QTest::newRow("Chinese (traditional)") << 9 << char16array(d3) << QByteArray(IDNA_ACE_PREFIX "ihqwctvzc91f659drss3x8bo0yb") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d4[] = { 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073, - 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076, - 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 }; - QTest::newRow("Czech") << 22 << ushortarray(d4) + char16_t d4[] = { 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073, + 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076, + 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 }; + QTest::newRow("Czech") << 22 << char16array(d4) << QByteArray(IDNA_ACE_PREFIX "Proprostnemluvesky-uyb24dma41a") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d5[] = { 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5, - 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9, - 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA }; - QTest::newRow("Hebrew") << 22 << ushortarray(d5) + char16_t d5[] = { 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5, + 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9, + 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA }; + QTest::newRow("Hebrew") << 22 << char16array(d5) << QByteArray(IDNA_ACE_PREFIX "4dbcagdahymbxekheh6e0a7fei0b") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d6[] = { 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928, - 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902, - 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938, - 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 }; - QTest::newRow("Hindi (Devanagari)") << 30 << ushortarray(d6) + char16_t d6[] = { 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928, + 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902, + 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938, + 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 }; + QTest::newRow("Hindi (Devanagari)") << 30 << char16array(d6) << QByteArray(IDNA_ACE_PREFIX "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd") << 0 << 0 << IDNA_SUCCESS; - unsigned short d7[] = { 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E, - 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044, - 0x306E, 0x304B }; - QTest::newRow("Japanese (kanji and hiragana)") << 18 << ushortarray(d7) + char16_t d7[] = { 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E, + 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044, + 0x306E, 0x304B }; + QTest::newRow("Japanese (kanji and hiragana)") << 18 << char16array(d7) << QByteArray(IDNA_ACE_PREFIX "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa") << 0 << 0 << IDNA_SUCCESS; - unsigned short d8[] = { 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435, - 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432, - 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443, - 0x0441, 0x0441, 0x043A, 0x0438 }; - QTest::newRow("Russian (Cyrillic)") << 28 << ushortarray(d8) + char16_t d8[] = { 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435, + 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432, + 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443, + 0x0441, 0x0441, 0x043A, 0x0438 }; + QTest::newRow("Russian (Cyrillic)") << 28 << char16array(d8) << QByteArray(IDNA_ACE_PREFIX "b1abfaaepdrnnbgefbadotcwatmq2g4l") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d9[] = { 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F, - 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069, - 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074, - 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065, - 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F, 0x006C }; - QTest::newRow("Spanish") << 40 << ushortarray(d9) + char16_t d9[] = { 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F, + 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069, + 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074, + 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065, + 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F, 0x006C }; + QTest::newRow("Spanish") << 40 << char16array(d9) << QByteArray(IDNA_ACE_PREFIX "PorqunopuedensimplementehablarenEspaol-fmd56a") << 0 << 0 << IDNA_SUCCESS; - unsigned short d10[] = { 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD, - 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3, - 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069, - 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 }; - QTest::newRow("Vietnamese") << 31 << ushortarray(d10) + char16_t d10[] = { 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD, + 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3, + 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069, + 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 }; + QTest::newRow("Vietnamese") << 31 << char16array(d10) << QByteArray(IDNA_ACE_PREFIX "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g") << 0 << 0 << IDNA_SUCCESS; - unsigned short d11[] = { 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148, 0x751F }; - QTest::newRow("Japanese") << 8 << ushortarray(d11) + char16_t d11[] = { 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148, 0x751F }; + QTest::newRow("Japanese") << 8 << char16array(d11) << QByteArray(IDNA_ACE_PREFIX "3B-ww4c5e180e575a65lsy2b") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; // this test does NOT include nameprepping, so the capitals will remain - unsigned short d12[] = { 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069, - 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052, - 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059, 0x0053 }; - QTest::newRow("Japanese2") << 24 << ushortarray(d12) + char16_t d12[] = { 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069, + 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052, + 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059, 0x0053 }; + QTest::newRow("Japanese2") << 24 << char16array(d12) << QByteArray(IDNA_ACE_PREFIX "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n") << 0 << 0 << IDNA_SUCCESS; - unsigned short d13[] = { 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E, - 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061, - 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834, - 0x6240 }; - QTest::newRow("Japanese3") << 25 << ushortarray(d13) + char16_t d13[] = { 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E, + 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061, + 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834, + 0x6240 }; + QTest::newRow("Japanese3") << 25 << char16array(d13) << QByteArray(IDNA_ACE_PREFIX "Hello-Another-Way--fc4qua05auwb3674vfr0b") << 0 << 0 << IDNA_SUCCESS; - unsigned short d14[] = { 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B, 0x0032 }; - QTest::newRow("Japanese4") << 8 << ushortarray(d14) + char16_t d14[] = { 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B, 0x0032 }; + QTest::newRow("Japanese4") << 8 << char16array(d14) << QByteArray(IDNA_ACE_PREFIX "2-u9tlzr9756bt3uc0v") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d15[] = { 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069, - 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D }; - QTest::newRow("Japanese5") << 13 << ushortarray(d15) + char16_t d15[] = { 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069, + 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D }; + QTest::newRow("Japanese5") << 13 << char16array(d15) << QByteArray(IDNA_ACE_PREFIX "MajiKoi5-783gue6qz075azm5e") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d16[] = { 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3, 0x30D0 }; - QTest::newRow("Japanese6") << 9 << ushortarray(d16) + char16_t d16[] = { 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3, 0x30D0 }; + QTest::newRow("Japanese6") << 9 << char16array(d16) << QByteArray(IDNA_ACE_PREFIX "de-jg4avhby1noc0d") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d17[] = { 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 }; - QTest::newRow("Japanese7") << 7 << ushortarray(d17) + char16_t d17[] = { 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 }; + QTest::newRow("Japanese7") << 7 << char16array(d17) << QByteArray(IDNA_ACE_PREFIX "d9juau41awczczp") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d18[] = { 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac }; - QTest::newRow("Greek") << 8 << ushortarray(d18) + char16_t d18[] = { 0x03b5, 0x03bb, 0x03bb, 0x03b7, 0x03bd, 0x03b9, 0x03ba, 0x03ac }; + QTest::newRow("Greek") << 8 << char16array(d18) << QByteArray(IDNA_ACE_PREFIX "hxargifdar") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d19[] = { 0x0062, 0x006f, 0x006e, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127, - 0x0127, 0x0061 }; - QTest::newRow("Maltese (Malti)") << 10 << ushortarray(d19) + char16_t d19[] = { 0x0062, 0x006f, 0x006e, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127, + 0x0127, 0x0061 }; + QTest::newRow("Maltese (Malti)") << 10 << char16array(d19) << QByteArray(IDNA_ACE_PREFIX "bonusaa-5bb1da") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; - unsigned short d20[] = {0x043f, 0x043e, 0x0447, 0x0435, 0x043c, 0x0443, 0x0436, 0x0435, - 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432, - 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443, - 0x0441, 0x0441, 0x043a, 0x0438 }; - QTest::newRow("Russian (Cyrillic)") << 28 << ushortarray(d20) + char16_t d20[] = {0x043f, 0x043e, 0x0447, 0x0435, 0x043c, 0x0443, 0x0436, 0x0435, + 0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432, + 0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443, + 0x0441, 0x0441, 0x043a, 0x0438 }; + QTest::newRow("Russian (Cyrillic)") << 28 << char16array(d20) << QByteArray(IDNA_ACE_PREFIX "b1abfaaepdrnnbgefbadotcwatmq2g4l") << 0 << 0 << IDNA_SUCCESS << IDNA_SUCCESS; } @@ -240,7 +240,7 @@ void tst_QUrlInternal::idna_testsuite_data() void tst_QUrlInternal::idna_testsuite() { QFETCH(int, numchars); - QFETCH(ushortarray, unicode); + QFETCH(char16array, unicode); QFETCH(QByteArray, punycode); QString result; diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index fed832f160..e9bdbb41aa 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -4464,14 +4464,14 @@ void tst_QString::fromLatin1Roundtrip_data() QTest::newRow("null") << QByteArray() << QString(); QTest::newRow("empty") << QByteArray("") << ""; - static const ushort unicode1[] = { 'H', 'e', 'l', 'l', 'o', 1, '\r', '\n', 0x7f }; + static const char16_t unicode1[] = { 'H', 'e', 'l', 'l', 'o', 1, '\r', '\n', 0x7f }; QTest::newRow("ascii-only") << QByteArray("Hello") << QString::fromUtf16(unicode1, 5); QTest::newRow("ascii+control") << QByteArray("Hello\1\r\n\x7f") << QString::fromUtf16(unicode1, 9); - static const ushort unicode3[] = { 'a', 0, 'z' }; + static const char16_t unicode3[] = { 'a', 0, 'z' }; QTest::newRow("ascii+nul") << QByteArray("a\0z", 3) << QString::fromUtf16(unicode3, 3); - static const ushort unicode4[] = { 0x80, 0xc0, 0xff }; + static const char16_t unicode4[] = { 0x80, 0xc0, 0xff }; QTest::newRow("non-ascii") << QByteArray("\x80\xc0\xff") << QString::fromUtf16(unicode4, 3); } @@ -4509,23 +4509,23 @@ void tst_QString::toLatin1Roundtrip_data() QTest::newRow("null") << QByteArray() << QString() << QString(); QTest::newRow("empty") << QByteArray("") << "" << ""; - static const ushort unicode1[] = { 'H', 'e', 'l', 'l', 'o', 1, '\r', '\n', 0x7f }; + static const char16_t unicode1[] = { 'H', 'e', 'l', 'l', 'o', 1, '\r', '\n', 0x7f }; QTest::newRow("ascii-only") << QByteArray("Hello") << QString::fromUtf16(unicode1, 5) << QString::fromUtf16(unicode1, 5); QTest::newRow("ascii+control") << QByteArray("Hello\1\r\n\x7f") << QString::fromUtf16(unicode1, 9) << QString::fromUtf16(unicode1, 9); - static const ushort unicode3[] = { 'a', 0, 'z' }; + static const char16_t unicode3[] = { 'a', 0, 'z' }; QTest::newRow("ascii+nul") << QByteArray("a\0z", 3) << QString::fromUtf16(unicode3, 3) << QString::fromUtf16(unicode3, 3); - static const ushort unicode4[] = { 0x80, 0xc0, 0xff }; + static const char16_t unicode4[] = { 0x80, 0xc0, 0xff }; QTest::newRow("non-ascii") << QByteArray("\x80\xc0\xff") << QString::fromUtf16(unicode4, 3) << QString::fromUtf16(unicode4, 3); - static const ushort unicodeq[] = { '?', '?', '?', '?', '?' }; + static const char16_t unicodeq[] = { '?', '?', '?', '?', '?' }; const QString questionmarks = QString::fromUtf16(unicodeq, 5); - static const ushort unicode5[] = { 0x100, 0x101, 0x17f, 0x7f00, 0x7f7f }; + static const char16_t unicode5[] = { 0x100, 0x101, 0x17f, 0x7f00, 0x7f7f }; QTest::newRow("non-latin1a") << QByteArray("?????") << QString::fromUtf16(unicode5, 5) << questionmarks; - static const ushort unicode6[] = { 0x180, 0x1ff, 0x8001, 0x8080, 0xfffc }; + static const char16_t unicode6[] = { 0x180, 0x1ff, 0x8001, 0x8080, 0xfffc }; QTest::newRow("non-latin1b") << QByteArray("?????") << QString::fromUtf16(unicode6, 5) << questionmarks; } @@ -4628,7 +4628,7 @@ void tst_QString::fromLatin1() void tst_QString::fromUcs4() { - const uint *null = 0; + const char32_t *null = 0; QString s; s = QString::fromUcs4( null ); QVERIFY( s.isNull() ); @@ -4640,7 +4640,7 @@ void tst_QString::fromUcs4() QVERIFY( s.isNull() ); QCOMPARE( s.size(), 0 ); - uint nil = '\0'; + char32_t nil = '\0'; s = QString::fromUcs4( &nil ); QVERIFY( !s.isNull() ); QCOMPARE( s.size(), 0 ); @@ -4648,12 +4648,12 @@ void tst_QString::fromUcs4() QVERIFY( !s.isNull() ); QCOMPARE( s.size(), 0 ); - uint bmp = 'a'; + char32_t bmp = 'a'; s = QString::fromUcs4( &bmp, 1 ); QVERIFY( !s.isNull() ); QCOMPARE( s.size(), 1 ); - uint smp = 0x10000; + char32_t smp = 0x10000; s = QString::fromUcs4( &smp, 1 ); QVERIFY( !s.isNull() ); QCOMPARE( s.size(), 2 ); @@ -4675,7 +4675,7 @@ void tst_QString::fromUcs4() // QTBUG-62011: don't mistake ZWNBS for BOM // Start with one BOM, to ensure we use the right endianness: - const uint text[] = { 0xfeff, 97, 0xfeff, 98, 0xfeff, 99, 0xfeff, 100 }; + const char32_t text[] = { 0xfeff, 97, 0xfeff, 98, 0xfeff, 99, 0xfeff, 100 }; s = QString::fromUcs4(text, 8); QCOMPARE(s, QStringView(u"a\xfeff" u"b\xfeff" u"c\xfeff" "d")); } @@ -5393,7 +5393,7 @@ void tst_QString::integer_conversion_data() QTest::newRow("C -0x10 16") << QString("-0x10") << 16 << true << (qlonglong)-16; // Let's try some Arabic - const quint16 arabic_str[] = { 0x0661, 0x0662, 0x0663, 0x0664, 0x0000 }; // "1234" + const char16_t arabic_str[] = { 0x0661, 0x0662, 0x0663, 0x0664, 0x0000 }; // "1234" QTest::newRow("ar_SA 1234 0") << QString::fromUtf16(arabic_str) << 0 << false << (qlonglong)0; } @@ -5456,7 +5456,7 @@ void tst_QString::double_conversion_data() QTest::newRow("C 1 ") << QString("1 ") << true << 1.0; // Let's try some Arabic - const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, + const char16_t arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, 0x0663, 0x0664, 0x0065, 0x0662, 0x0000 }; // "0.1234e2" QTest::newRow("ar_SA") << QString::fromUtf16(arabic_str) << false << 0.0; @@ -7001,16 +7001,16 @@ void tst_QString::isRightToLeft_data() QTest::newRow("latin1-only") << QString("hello") << false; QTest::newRow("numbers-latin1") << (QString("12345") + QString("hello")) << false; - static const ushort unicode1[] = { 0x627, 0x627 }; + static const char16_t unicode1[] = { 0x627, 0x627 }; QTest::newRow("arabic-only") << QString::fromUtf16(unicode1, 2) << true; QTest::newRow("numbers-arabic") << (QString("12345") + QString::fromUtf16(unicode1, 2)) << true; QTest::newRow("numbers-latin1-arabic") << (QString("12345") + QString("hello") + QString::fromUtf16(unicode1, 2)) << false; QTest::newRow("numbers-arabic-latin1") << (QString("12345") + QString::fromUtf16(unicode1, 2) + QString("hello")) << true; - static const ushort unicode2[] = { QChar::highSurrogate(0xE01DAu), QChar::lowSurrogate(0xE01DAu), QChar::highSurrogate(0x2F800u), QChar::lowSurrogate(0x2F800u) }; + static const char16_t unicode2[] = { QChar::highSurrogate(0xE01DAu), QChar::lowSurrogate(0xE01DAu), QChar::highSurrogate(0x2F800u), QChar::lowSurrogate(0x2F800u) }; QTest::newRow("surrogates-VS-CJK") << QString::fromUtf16(unicode2, 4) << false; - static const ushort unicode3[] = { QChar::highSurrogate(0x10800u), QChar::lowSurrogate(0x10800u), QChar::highSurrogate(0x10805u), QChar::lowSurrogate(0x10805u) }; + static const char16_t 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; diff --git a/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp b/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp index 922063e779..2ca1d13d4c 100644 --- a/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp +++ b/tests/auto/corelib/text/qstringiterator/tst_qstringiterator.cpp @@ -195,8 +195,8 @@ void tst_QStringIterator::sweep() QString rebuiltString; while (i.hasNext()) { - const uint peekedCodePoint = i.peekNext(~0u); - const uint codePoint = i.next(~0u); + const char32_t peekedCodePoint = i.peekNext(~0u); + const char32_t codePoint = i.next(~0u); QVERIFY(peekedCodePoint == codePoint); @@ -213,8 +213,8 @@ void tst_QStringIterator::sweep() rebuiltString.clear(); while (i.hasPrevious()) { - const uint peekedCodePoint = i.peekPrevious(~0u); - const uint codePoint = i.previous(~0u); + const char32_t peekedCodePoint = i.peekPrevious(~0u); + const char32_t codePoint = i.previous(~0u); QVERIFY(peekedCodePoint == codePoint); @@ -239,8 +239,8 @@ void tst_QStringIterator::sweep() if (valid) { while (i.hasNext()) { - const uint peekedCodePoint = i.peekNextUnchecked(); - const uint codePoint = i.nextUnchecked(); + const char32_t peekedCodePoint = i.peekNextUnchecked(); + const char32_t codePoint = i.nextUnchecked(); QVERIFY(peekedCodePoint == codePoint); QVERIFY(codePoint <= 0x10FFFFu); @@ -252,8 +252,8 @@ void tst_QStringIterator::sweep() QTEST(rebuiltString, "string"); while (i.hasPrevious()) { - const uint peekedCodePoint = i.peekPreviousUnchecked(); - const uint codePoint = i.previousUnchecked(); + const char32_t peekedCodePoint = i.peekPreviousUnchecked(); + const char32_t codePoint = i.previousUnchecked(); QVERIFY(peekedCodePoint == codePoint); diff --git a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp index f8049ffabc..25f56a5df0 100644 --- a/tests/auto/corelib/text/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/text/qstringref/tst_qstringref.cpp @@ -1786,7 +1786,7 @@ void tst_QStringRef::integer_conversion_data() QTest::newRow("C -0x10 16") << QString("-0x10") << 16 << true << (qlonglong)-16; // Let's try some Arabic - const quint16 arabic_str[] = { 0x0661, 0x0662, 0x0663, 0x0664, 0x0000 }; // "1234" + const char16_t arabic_str[] = { 0x0661, 0x0662, 0x0663, 0x0664, 0x0000 }; // "1234" QTest::newRow("ar_SA 1234 0") << QString::fromUtf16(arabic_str) << 0 << false << (qlonglong)0; } @@ -1850,7 +1850,7 @@ void tst_QStringRef::double_conversion_data() QTest::newRow("C 1 ") << QString("1 ") << true << 1.0; // Let's try some Arabic - const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, + const char16_t arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, 0x0663, 0x0664, 0x0065, 0x0662, 0x0000 }; // "0.1234e2" QTest::newRow("ar_SA") << QString::fromUtf16(arabic_str) << false << 0.0; |