diff options
Diffstat (limited to 'tests/auto/corelib/text/qstring/tst_qstring.cpp')
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 35bddf16a4..92ea5b013d 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -6647,9 +6647,41 @@ void tst_QString::arg() // number overloads QCOMPARE( s4.arg(0), QLatin1String("[0]") ); QCOMPARE( s4.arg(-1), QLatin1String("[-1]") ); + QCOMPARE( s4.arg(0U), QLatin1String("[0]")); + QCOMPARE( s4.arg(qint8(-128)), QLatin1String("[-128]")); // signed char + QCOMPARE( s4.arg(quint8(255)), QLatin1String("[255]")); // unsigned char + QCOMPARE( s4.arg(short(-4200)), QLatin1String("[-4200]")); + QCOMPARE( s4.arg(ushort(42000)), QLatin1String("[42000]")); QCOMPARE( s4.arg(4294967295UL), QLatin1String("[4294967295]") ); // ULONG_MAX 32 QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX QLatin1String("[9223372036854775807]") ); + QCOMPARE( s4.arg(Q_UINT64_C(9223372036854775808)), // LLONG_MAX + 1 + QLatin1String("[9223372036854775808]") ); + + // FP overloads + QCOMPARE(s4.arg(2.25), QLatin1String("[2.25]")); + QCOMPARE(s4.arg(3.75f), QLatin1String("[3.75]")); +#if !QFLOAT16_IS_NATIVE // QTBUG-126055 + QCOMPARE(s4.arg(qfloat16{4.125f}), QLatin1String("[4.125]")); +#endif + + // char-ish overloads + QCOMPARE(s4.arg('\xE4'), QStringView(u"[ä]")); + QEXPECT_FAIL("", "QTBUG-125588", Continue); + QCOMPARE(s4.arg(u'ø'), QStringView(u"[ø]")); +#ifdef Q_OS_WIN + QCOMPARE(QLatin1String("[%1]").arg(L'ø'), QStringView(u"[ø]")); +#endif + QEXPECT_FAIL("", "QTBUG-126054", Continue); + QCOMPARE(s4.arg(L'ø'), QStringView(u"[ø]")); +#ifndef __cpp_char8_t +#ifndef QT_NO_CAST_FROM_ASCII + QCOMPARE(QLatin1String("[%1]").arg(u8'a'), QLatin1String("[a]")); +#endif +#else + QEXPECT_FAIL("", "QTBUG-126053", Continue); +#endif + QCOMPARE(s4.arg(u8'a'), QLatin1String("[a]")); QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: , foo"); QCOMPARE(QString().arg(foo), QString()); @@ -6721,9 +6753,15 @@ void tst_QString::arg() str = str.arg(u"ahoy"_s, u"there"_s); QCOMPARE(str, "one 2 3 4 5 6 7 8 9 foo ahoy there bar"_L1); - QString str2(u"%123 %234 %345 %456 %567 %999 %1000 %1230"_s); - str2 = str2.arg(u"A"_s, u"B"_s, u"C"_s, u"D"_s, u"E"_s, u"F"_s); - QCOMPARE(str2, QLatin1String("A B C D E F %1000 %1230")); + // Make sure the single- and multi-arg expand the same sequences: at most + // two digits. The sequence below has four replacements: %01, %10 (twice), + // %11, and %12. + QString str2 = u"%100 %101 %110 %12 %0100"_s; + QLatin1StringView str2expected = "B0 B1 C0 D A00"_L1; + QCOMPARE(str2.arg(QChar(u'A')).arg(QChar(u'B')).arg(QChar(u'C')).arg(QChar(u'D')), str2expected); + QCOMPARE(str2.arg(QChar(u'A'), QChar(u'B')).arg(QChar(u'C')).arg(QChar(u'D')), str2expected); + QCOMPARE(str2.arg(QChar(u'A'), QChar(u'B'), QChar(u'C')).arg(QChar(u'D')), str2expected); + QCOMPARE(str2.arg(QChar(u'A'), QChar(u'B'), QChar(u'C'), QChar(u'D')), str2expected); QCOMPARE(u"%1"_s.arg(-1, 3, 10, QChar(u'0')), "-01"_L1); QCOMPARE(u"%1"_s.arg(-100, 3, 10, QChar(u'0')), "-100"_L1); |