QString: change test data to compile with QT_NO_CAST_FROM_ASCII [8/13]
Pick-to: 6.5 Change-Id: I72ebb7bb19e35a10aa85ea7da6ee6b1b332050a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
19b52ad2e5
commit
448683809b
|
|
@ -2896,150 +2896,150 @@ void tst_QString::insert_special_cases()
|
|||
|
||||
{
|
||||
// Test when string is not shared
|
||||
a = "Ys";
|
||||
QCOMPARE(a.insert(1,'e'), QString("Yes"));
|
||||
QCOMPARE(a.insert(3,'!'), QString("Yes!"));
|
||||
QCOMPARE(a.insert(5,'?'), QString("Yes! ?"));
|
||||
QCOMPARE(a.insert(-1,'a'), QString("Yes! a?"));
|
||||
a = u"Ys"_s;
|
||||
QCOMPARE(a.insert(1, u'e'), u"Yes");
|
||||
QCOMPARE(a.insert(3, u'!'), u"Yes!");
|
||||
QCOMPARE(a.insert(5, u'?'), u"Yes! ?");
|
||||
QCOMPARE(a.insert(-1, u'a'), u"Yes! a?");
|
||||
}
|
||||
{
|
||||
// Test when string is shared
|
||||
a = "Ys";
|
||||
a = u"Ys"_s;
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(1,'e'), QString("Yes"));
|
||||
QCOMPARE(a.insert(1, u'e'), u"Yes");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(3,'!'), QString("Yes!"));
|
||||
QCOMPARE(a.insert(3, u'!'), u"Yes!");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(5,'?'), QString("Yes! ?"));
|
||||
QCOMPARE(a.insert(5, u'?'), u"Yes! ?");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(-1,'a'), QString("Yes! a?"));
|
||||
QCOMPARE(a.insert(-1, u'a'), u"Yes! a?");
|
||||
}
|
||||
|
||||
a = "ABC";
|
||||
a = u"ABC"_s;
|
||||
dummy_share = a;
|
||||
QCOMPARE(dummy_share.insert(5,"DEF"), QString("ABC DEF")); // Shared
|
||||
QCOMPARE(a.insert(5,"DEF"), QString("ABC DEF")); // Not shared after dummy_shared.insert()
|
||||
QCOMPARE(dummy_share.insert(5, u"DEF"_s), u"ABC DEF"_s); // Shared
|
||||
QCOMPARE(a.insert(5, u"DEF"_s), u"ABC DEF"_s); // Not shared after dummy_shared.insert()
|
||||
|
||||
{
|
||||
// Test when string is not shared
|
||||
a = "ABC";
|
||||
QCOMPARE(a.insert(2, QString()), QString("ABC"));
|
||||
QCOMPARE(a.insert(0,"ABC"), QString("ABCABC"));
|
||||
QCOMPARE(a, QString("ABCABC"));
|
||||
QCOMPARE(a.insert(0,a), QString("ABCABCABCABC"));
|
||||
a = u"ABC"_s;
|
||||
QCOMPARE(a.insert(2, QString()), u"ABC");
|
||||
QCOMPARE(a.insert(0, u"ABC"_s), u"ABCABC");
|
||||
QCOMPARE(a, u"ABCABC");
|
||||
QCOMPARE(a.insert(0, a), u"ABCABCABCABC");
|
||||
|
||||
QCOMPARE(a, QString("ABCABCABCABC"));
|
||||
QCOMPARE(a.insert(0,'<'), QString("<ABCABCABCABC"));
|
||||
QCOMPARE(a.insert(1,'>'), QString("<>ABCABCABCABC"));
|
||||
QCOMPARE(a, u"ABCABCABCABC");
|
||||
QCOMPARE(a.insert(0, u'<'), u"<ABCABCABCABC");
|
||||
QCOMPARE(a.insert(1, u'>'), u"<>ABCABCABCABC");
|
||||
}
|
||||
{
|
||||
// Test when string is shared
|
||||
a = "ABC";
|
||||
a = u"ABC"_s;
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(2, QString()), QString("ABC"));
|
||||
QCOMPARE(a.insert(2, QString()), u"ABC");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(0,"ABC"), QString("ABCABC"));
|
||||
QCOMPARE(a.insert(0, u"ABC"_s), u"ABCABC");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a, QString("ABCABC"));
|
||||
QCOMPARE(a, u"ABCABC");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(0,a), QString("ABCABCABCABC"));
|
||||
QCOMPARE(a.insert(0, a), u"ABCABCABCABC");
|
||||
|
||||
QCOMPARE(a, QString("ABCABCABCABC"));
|
||||
QCOMPARE(a, u"ABCABCABCABC");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(0,'<'), QString("<ABCABCABCABC"));
|
||||
QCOMPARE(a.insert(0, u'<'), u"<ABCABCABCABC");
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(1,'>'), QString("<>ABCABCABCABC"));
|
||||
QCOMPARE(a.insert(1, u'>'), u"<>ABCABCABCABC");
|
||||
}
|
||||
|
||||
const QString montreal = QStringLiteral("Montreal");
|
||||
{
|
||||
// Test when string is not shared
|
||||
a = "Meal";
|
||||
QCOMPARE(a.insert(1, QLatin1String("ontr")), montreal);
|
||||
QCOMPARE(a.insert(4, ""), montreal);
|
||||
QCOMPARE(a.insert(3, QLatin1String("")), montreal);
|
||||
a = u"Meal"_s;
|
||||
QCOMPARE(a.insert(1, "ontr"_L1), montreal);
|
||||
QCOMPARE(a.insert(4, ""_L1), montreal);
|
||||
QCOMPARE(a.insert(3, ""_L1), montreal);
|
||||
QCOMPARE(a.insert(3, QLatin1String(nullptr)), montreal);
|
||||
QCOMPARE(a.insert(3, static_cast<const char *>(0)), montreal);
|
||||
QCOMPARE(a.insert(0, QLatin1String("a")), QLatin1String("aMontreal"));
|
||||
QCOMPARE(a.insert(0, u"a"_s), "aMontreal"_L1);
|
||||
}
|
||||
{
|
||||
// Test when string is shared
|
||||
a = "Meal";
|
||||
a = u"Meal"_s;
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(1, QLatin1String("ontr")), montreal);
|
||||
QCOMPARE(a.insert(1, "ontr"_L1), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(4, ""), montreal);
|
||||
QCOMPARE(a.insert(4, ""_L1), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(3, QLatin1String("")), montreal);
|
||||
QCOMPARE(a.insert(3, ""_L1), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(3, QLatin1String(nullptr)), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(3, static_cast<const char *>(0)), montreal);
|
||||
QCOMPARE(a.insert(3, QLatin1String(static_cast<const char *>(0))), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(0, QLatin1String("a")), QLatin1String("aMontreal"));
|
||||
QCOMPARE(a.insert(0, u"a"_s), "aMontreal"_L1);
|
||||
}
|
||||
|
||||
{
|
||||
// Test when string is not shared
|
||||
a = "Mont";
|
||||
QCOMPARE(a.insert(a.size(), QLatin1String("real")), montreal);
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String("ABC")), QString("Montreal ABC"));
|
||||
a = u"Mont"_s;
|
||||
QCOMPARE(a.insert(a.size(), "real"_L1), montreal);
|
||||
QCOMPARE(a.insert(a.size() + 1, "ABC"_L1), u"Montreal ABC");
|
||||
}
|
||||
{
|
||||
// Test when string is shared
|
||||
a = "Mont";
|
||||
a = u"Mont"_s;
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(a.size(), QLatin1String("real")), montreal);
|
||||
QCOMPARE(a.insert(a.size(), "real"_L1), montreal);
|
||||
dummy_share = a;
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String("ABC")), QString("Montreal ABC"));
|
||||
QCOMPARE(a.insert(a.size() + 1, "ABC"_L1), u"Montreal ABC");
|
||||
}
|
||||
|
||||
{
|
||||
// Test when string is not shared
|
||||
a = "AEF";
|
||||
QCOMPARE(a.insert(1, QLatin1String("BCD")), QString("ABCDEF"));
|
||||
QCOMPARE(a.insert(3, QLatin1String("-")), QString("ABC-DEF"));
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String("XYZ")), QString("ABC-DEF XYZ"));
|
||||
a = u"AEF"_s;
|
||||
QCOMPARE(a.insert(1, "BCD"_L1), u"ABCDEF");
|
||||
QCOMPARE(a.insert(3, "-"_L1), u"ABC-DEF");
|
||||
QCOMPARE(a.insert(a.size() + 1, "XYZ"_L1), u"ABC-DEF XYZ");
|
||||
}
|
||||
|
||||
{
|
||||
// Test when string is shared
|
||||
a = "AEF";
|
||||
a = u"AEF"_s;
|
||||
dummy_share = a ;
|
||||
QCOMPARE(a.insert(1, QLatin1String("BCD")), QString("ABCDEF"));
|
||||
QCOMPARE(a.insert(1, "BCD"_L1), u"ABCDEF");
|
||||
dummy_share = a ;
|
||||
QCOMPARE(a.insert(3, QLatin1String("-")), QString("ABC-DEF"));
|
||||
QCOMPARE(a.insert(3, "-"_L1), u"ABC-DEF");
|
||||
dummy_share = a ;
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String("XYZ")), QString("ABC-DEF XYZ"));
|
||||
QCOMPARE(a.insert(a.size() + 1, "XYZ"_L1), u"ABC-DEF XYZ");
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
a = "one";
|
||||
a = u"one"_s;
|
||||
a.prepend(u'a');
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd(), u'b');
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String(b.toLatin1())), QString("aone ") + b);
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String(b.toLatin1())), u"aone "_s + b);
|
||||
}
|
||||
{
|
||||
a = "one";
|
||||
a = u"one"_s;
|
||||
a.prepend(u'a');
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd(), u'b');
|
||||
QCOMPARE(a.insert(a.size() + 1, b), QString("aone ") + b);
|
||||
QCOMPARE(a.insert(a.size() + 1, b), u"aone "_s + b);
|
||||
}
|
||||
|
||||
{
|
||||
a = "onetwothree";
|
||||
a = u"onetwothree"_s;
|
||||
while (a.size() - 1)
|
||||
a.remove(0, 1);
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd() + 1, u'b');
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String(b.toLatin1())), QString("e ") + b);
|
||||
QCOMPARE(a.insert(a.size() + 1, QLatin1String(b.toLatin1())), u"e "_s + b);
|
||||
}
|
||||
{
|
||||
a = "onetwothree";
|
||||
a = u"onetwothree"_s;
|
||||
while (a.size() - 1)
|
||||
a.remove(0, 1);
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd() + 1, u'b');
|
||||
QCOMPARE(a.insert(a.size() + 1, b), QString("e ") + b);
|
||||
QCOMPARE(a.insert(a.size() + 1, b), u"e "_s + b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3140,10 +3140,10 @@ void tst_QString::append_special_cases()
|
|||
{
|
||||
{
|
||||
QString a;
|
||||
static const QChar unicode[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!' };
|
||||
static const QChar unicode[] = { u'H', u'e', u'l', u'l', u'o', u',', u' ', u'W', u'o', u'r', u'l', u'd', u'!' };
|
||||
a.append(unicode, sizeof unicode / sizeof *unicode);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!"));
|
||||
static const QChar nl('\n');
|
||||
static const QChar nl(u'\n');
|
||||
a.append(&nl, 1);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!\n"));
|
||||
a.append(unicode, sizeof unicode / sizeof *unicode);
|
||||
|
|
@ -3166,45 +3166,45 @@ void tst_QString::append_special_cases()
|
|||
}
|
||||
|
||||
{
|
||||
QString a = "one";
|
||||
QString a = u"one"_s;
|
||||
a.prepend(u'a');
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd(), u'b');
|
||||
QCOMPARE(a.append(QLatin1String(b.toLatin1())), QString("aone") + b);
|
||||
QCOMPARE(a.append(QLatin1String(b.toLatin1())), u"aone"_s + b);
|
||||
}
|
||||
|
||||
{
|
||||
QString a = "onetwothree";
|
||||
QString a = u"onetwothree"_s;
|
||||
while (a.size() - 1)
|
||||
a.remove(0, 1);
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd(), u'b');
|
||||
QCOMPARE(a.append(QLatin1String(b.toLatin1())), QString("e") + b);
|
||||
QCOMPARE(a.append(QLatin1String(b.toLatin1())), u'e' + b);
|
||||
}
|
||||
|
||||
{
|
||||
QString a = "one";
|
||||
QString a = u"one"_s;
|
||||
a.prepend(u'a');
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd(), u'b');
|
||||
QCOMPARE(a.append(b), QString("aone") + b);
|
||||
QCOMPARE(a.append(b), u"aone"_s + b);
|
||||
}
|
||||
|
||||
{
|
||||
QString a = "onetwothree";
|
||||
QString a = u"onetwothree"_s;
|
||||
while (a.size() - 1)
|
||||
a.remove(0, 1);
|
||||
QString b(a.data_ptr()->freeSpaceAtEnd() + 1, u'b');
|
||||
QCOMPARE(a.append(b), QString("e") + b);
|
||||
QCOMPARE(a.append(b), u'e' + b);
|
||||
}
|
||||
|
||||
{
|
||||
QString a = "one";
|
||||
QString a = u"one"_s;
|
||||
a.prepend(u'a');
|
||||
QCOMPARE(a.append(u'b'), QString("aoneb"));
|
||||
QCOMPARE(a.append(u'b'), u"aoneb");
|
||||
}
|
||||
|
||||
{
|
||||
QString a = "onetwothree";
|
||||
QString a = u"onetwothree"_s;
|
||||
a.erase(a.cbegin(), std::prev(a.cend()));
|
||||
QCOMPARE(a.append(u'b'), QString("eb"));
|
||||
QCOMPARE(a.append(u'b'), u"eb");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3344,9 +3344,8 @@ void tst_QString::operator_eqeq_bytearray()
|
|||
|
||||
void tst_QString::swap()
|
||||
{
|
||||
QString s1, s2;
|
||||
s1 = "s1";
|
||||
s2 = "s2";
|
||||
QString s1 = QString::fromUtf8("s1");
|
||||
QString s2 = QString::fromUtf8("s2");
|
||||
s1.swap(s2);
|
||||
QCOMPARE(s1,QLatin1String("s2"));
|
||||
QCOMPARE(s2,QLatin1String("s1"));
|
||||
|
|
@ -3555,9 +3554,9 @@ void tst_QString::replace_uint_uint_extra()
|
|||
{
|
||||
{
|
||||
QString s;
|
||||
s.insert(0, QChar('A'));
|
||||
s.insert(0, QChar(u'A'));
|
||||
|
||||
auto bigReplacement = QString("B").repeated(s.capacity() * 3);
|
||||
auto bigReplacement = QString(u'B').repeated(s.capacity() * 3);
|
||||
|
||||
s.replace( 0, 1, bigReplacement );
|
||||
QCOMPARE( s, bigReplacement );
|
||||
|
|
@ -3567,7 +3566,7 @@ void tst_QString::replace_uint_uint_extra()
|
|||
QString s;
|
||||
s.insert(0, QLatin1String("BBB"));
|
||||
|
||||
auto smallReplacement = QString("C");
|
||||
auto smallReplacement = QString(u'C');
|
||||
|
||||
s.replace( 0, 3, smallReplacement );
|
||||
QCOMPARE( s, smallReplacement );
|
||||
|
|
@ -3577,7 +3576,7 @@ void tst_QString::replace_uint_uint_extra()
|
|||
QString s;
|
||||
s.insert(0, QLatin1String("BBB"));
|
||||
|
||||
auto smallReplacement = QString("C");
|
||||
auto smallReplacement = QString(u'C');
|
||||
|
||||
s.replace( 5, 3, smallReplacement );
|
||||
QCOMPARE( s, QLatin1String("BBB") );
|
||||
|
|
@ -3590,11 +3589,11 @@ void tst_QString::replace_extra()
|
|||
This test is designed to be extremely slow if QString::replace() doesn't optimize the case
|
||||
len == after.size().
|
||||
*/
|
||||
QString str("dsfkljfdsjklsdjsfjklfsdjkldfjslkjsdfkllkjdsfjklsfdkjsdflkjlsdfjklsdfkjldsflkjsddlkj");
|
||||
QString str(u"dsfkljfdsjklsdjsfjklfsdjkldfjslkjsdfkllkjdsfjklsfdkjsdflkjlsdfjklsdfkjldsflkjsddlkj"_s);
|
||||
for (int j = 1; j < 12; ++j)
|
||||
str += str;
|
||||
|
||||
QString str2("aaaaaaaaaaaaaaaaaaaa");
|
||||
QString str2(u"aaaaaaaaaaaaaaaaaaaa"_s);
|
||||
for (int i = 0; i < 2000000; ++i) {
|
||||
str.replace(10, 20, str2);
|
||||
}
|
||||
|
|
@ -3610,26 +3609,26 @@ void tst_QString::replace_extra()
|
|||
/*
|
||||
Make sure that replacing a part of oneself with itself works.
|
||||
*/
|
||||
QString str3("abcdefghij");
|
||||
QString str3(u"abcdefghij"_s);
|
||||
str3.replace(0, 1, str3);
|
||||
QCOMPARE(str3, QString("abcdefghijbcdefghij"));
|
||||
QCOMPARE(str3, u"abcdefghijbcdefghij");
|
||||
|
||||
QString str4("abcdefghij");
|
||||
QString str4(u"abcdefghij"_s);
|
||||
str4.replace(1, 3, str4);
|
||||
QCOMPARE(str4, QString("aabcdefghijefghij"));
|
||||
QCOMPARE(str4, u"aabcdefghijefghij");
|
||||
|
||||
QString str5("abcdefghij");
|
||||
QString str5(u"abcdefghij"_s);
|
||||
str5.replace(8, 10, str5);
|
||||
QCOMPARE(str5, QString("abcdefghabcdefghij"));
|
||||
QCOMPARE(str5, u"abcdefghabcdefghij");
|
||||
|
||||
// Replacements using only part of the string modified:
|
||||
QString str6("abcdefghij");
|
||||
QString str6(u"abcdefghij"_s);
|
||||
str6.replace(1, 8, str6.constData() + 3, 3);
|
||||
QCOMPARE(str6, QString("adefj"));
|
||||
QCOMPARE(str6, u"adefj");
|
||||
|
||||
QString str7("abcdefghibcdefghij");
|
||||
QString str7(u"abcdefghibcdefghij"_s);
|
||||
str7.replace(str7.constData() + 1, 6, str7.constData() + 2, 3);
|
||||
QCOMPARE(str7, QString("acdehicdehij"));
|
||||
QCOMPARE(str7, u"acdehicdehij");
|
||||
|
||||
const int many = 1024;
|
||||
/*
|
||||
|
|
@ -3638,7 +3637,8 @@ void tst_QString::replace_extra()
|
|||
changes to batch size), which lead to misbehaviour if ether QChar * array
|
||||
was part of the data being modified.
|
||||
*/
|
||||
QString str8("abcdefg"), ans8("acdeg");
|
||||
QString str8(u"abcdefg"_s);
|
||||
QString ans8(u"acdeg"_s);
|
||||
{
|
||||
// Make str8 and ans8 repeat themselves many + 1 times:
|
||||
int i = many;
|
||||
|
|
@ -3694,11 +3694,11 @@ void tst_QString::replace_string_extra()
|
|||
{
|
||||
{
|
||||
QString s;
|
||||
s.insert(0, QChar('A'));
|
||||
s.insert(0, u'A');
|
||||
|
||||
auto bigReplacement = QString("B").repeated(s.capacity() * 3);
|
||||
auto bigReplacement = QString(u'B').repeated(s.capacity() * 3);
|
||||
|
||||
s.replace( QString("A"), bigReplacement );
|
||||
s.replace( u"A"_s, bigReplacement );
|
||||
QCOMPARE( s, bigReplacement );
|
||||
}
|
||||
|
||||
|
|
@ -3706,9 +3706,9 @@ void tst_QString::replace_string_extra()
|
|||
QString s;
|
||||
s.insert(0, QLatin1String("BBB"));
|
||||
|
||||
auto smallReplacement = QString("C");
|
||||
auto smallReplacement = QString(u'C');
|
||||
|
||||
s.replace( QString("BBB"), smallReplacement );
|
||||
s.replace( u"BBB"_s, smallReplacement );
|
||||
QCOMPARE( s, smallReplacement );
|
||||
}
|
||||
|
||||
|
|
@ -3716,10 +3716,10 @@ void tst_QString::replace_string_extra()
|
|||
QString s(QLatin1String("BBB"));
|
||||
QString expected(QLatin1String("BBB"));
|
||||
for (int i = 0; i < 1028; ++i) {
|
||||
s.append("X");
|
||||
expected.append("GXU");
|
||||
s.append(u'X');
|
||||
expected.append(u"GXU"_s);
|
||||
}
|
||||
s.replace(QChar('X'), "GXU");
|
||||
s.replace(QChar(u'X'), u"GXU"_s);
|
||||
QCOMPARE(s, expected);
|
||||
}
|
||||
}
|
||||
|
|
@ -3746,11 +3746,11 @@ void tst_QString::replace_regexp_extra()
|
|||
{
|
||||
{
|
||||
QString s;
|
||||
s.insert(0, QChar('A'));
|
||||
s.insert(0, QChar(u'A'));
|
||||
|
||||
auto bigReplacement = QString("B").repeated(s.capacity() * 3);
|
||||
auto bigReplacement = QString(u'B').repeated(s.capacity() * 3);
|
||||
|
||||
QRegularExpression regularExpression(QString("A"));
|
||||
QRegularExpression regularExpression(u"A"_s);
|
||||
QVERIFY(regularExpression.isValid());
|
||||
|
||||
s.replace( regularExpression, bigReplacement );
|
||||
|
|
@ -3761,9 +3761,9 @@ void tst_QString::replace_regexp_extra()
|
|||
QString s;
|
||||
s.insert(0, QLatin1String("BBB"));
|
||||
|
||||
auto smallReplacement = QString("C");
|
||||
auto smallReplacement = QString(u'C');
|
||||
|
||||
QRegularExpression regularExpression(QString("BBB"));
|
||||
QRegularExpression regularExpression(u"BBB"_s);
|
||||
QVERIFY(regularExpression.isValid());
|
||||
|
||||
s.replace( regularExpression, smallReplacement );
|
||||
|
|
@ -3877,7 +3877,7 @@ void tst_QString::remove_regexp_data()
|
|||
void tst_QString::remove_regexp()
|
||||
{
|
||||
static const QRegularExpression ignoreMessagePattern(
|
||||
"^QString::replace\\(\\): called on an invalid QRegularExpression object"
|
||||
u"^QString::replace\\(\\): called on an invalid QRegularExpression object"_s
|
||||
);
|
||||
|
||||
QFETCH( QString, string );
|
||||
|
|
@ -3897,7 +3897,7 @@ void tst_QString::remove_extra()
|
|||
{
|
||||
{
|
||||
QString quickFox = "The quick brown fox jumps over the lazy dog. "
|
||||
"The lazy dog jumps over the quick brown fox.";
|
||||
"The lazy dog jumps over the quick brown fox."_L1;
|
||||
QString s1 = quickFox;
|
||||
QVERIFY(s1.data_ptr().needsDetach());
|
||||
s1.remove(s1);
|
||||
|
|
@ -3910,7 +3910,7 @@ void tst_QString::remove_extra()
|
|||
}
|
||||
|
||||
{
|
||||
QString s = "BCDEFGHJK";
|
||||
QString s = u"BCDEFGHJK"_s;
|
||||
QString s1 = s;
|
||||
s1.insert(0, u'A'); // detaches
|
||||
s1.erase(s1.cbegin());
|
||||
|
|
@ -3918,13 +3918,13 @@ void tst_QString::remove_extra()
|
|||
}
|
||||
|
||||
{
|
||||
QString s = "Clock";
|
||||
QString s = u"Clock"_s;
|
||||
s.removeFirst();
|
||||
QCOMPARE(s, "lock");
|
||||
QCOMPARE(s, u"lock");
|
||||
s.removeLast();
|
||||
QCOMPARE(s, "loc");
|
||||
s.removeAt(s.indexOf('o'));
|
||||
QCOMPARE(s, "lc");
|
||||
QCOMPARE(s, u"loc");
|
||||
s.removeAt(s.indexOf(u'o'));
|
||||
QCOMPARE(s, u"lc");
|
||||
s.clear();
|
||||
// No crash on empty strings
|
||||
s.removeFirst();
|
||||
|
|
@ -3935,39 +3935,39 @@ void tst_QString::remove_extra()
|
|||
|
||||
void tst_QString::erase_single_arg()
|
||||
{
|
||||
QString s = "abcdefg";
|
||||
QString s = u"abcdefg"_s;
|
||||
auto it = s.erase(s.cbegin());
|
||||
QCOMPARE_EQ(s, "bcdefg");
|
||||
QCOMPARE_EQ(s, u"bcdefg");
|
||||
QCOMPARE(it, s.cbegin());
|
||||
|
||||
it = s.erase(std::prev(s.end()));
|
||||
QCOMPARE_EQ(s, "bcdef");
|
||||
QCOMPARE_EQ(s, u"bcdef");
|
||||
QCOMPARE(it, s.cend());
|
||||
|
||||
it = s.erase(std::find(s.begin(), s.end(), QChar('d')));
|
||||
it = s.erase(std::find(s.begin(), s.end(), QChar(u'd')));
|
||||
QCOMPARE(it, s.begin() + 2);
|
||||
}
|
||||
|
||||
void tst_QString::erase()
|
||||
{
|
||||
QString str = "abcdefg";
|
||||
QString str = u"abcdefg"_s;
|
||||
|
||||
QString s = str;
|
||||
auto it = s.erase(s.begin(), s.end());
|
||||
QCOMPARE_EQ(s, "");
|
||||
QCOMPARE_EQ(s, u"");
|
||||
QCOMPARE(it, s.end());
|
||||
|
||||
s = str;
|
||||
it = s.erase(std::prev(s.end()));
|
||||
QCOMPARE_EQ(s, "abcdef");
|
||||
QCOMPARE_EQ(s, u"abcdef");
|
||||
QCOMPARE(it, s.end());
|
||||
|
||||
it = s.erase(s.begin() + 2, s.end());
|
||||
QCOMPARE_EQ(s, "ab");
|
||||
QCOMPARE_EQ(s, u"ab");
|
||||
QCOMPARE(it, s.end());
|
||||
|
||||
it = s.erase(s.begin(), s.begin() + 1);
|
||||
QCOMPARE_EQ(s, "b");
|
||||
QCOMPARE_EQ(s, u"b");
|
||||
QCOMPARE(it, s.begin());
|
||||
|
||||
{
|
||||
|
|
@ -3976,8 +3976,8 @@ void tst_QString::erase()
|
|||
// erase() should return an iterator, not const_iterator
|
||||
auto it = s1.erase(s1.cbegin(), s1.cbegin());
|
||||
*it = QLatin1Char('m');
|
||||
QCOMPARE(s1, "mouse");
|
||||
QCOMPARE(copy, "house");
|
||||
QCOMPARE(s1, u"mouse");
|
||||
QCOMPARE(copy, u"house");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3985,11 +3985,11 @@ void tst_QString::toNum()
|
|||
{
|
||||
#if defined (Q_OS_WIN) && defined (Q_CC_MSVC)
|
||||
#define TEST_TO_INT(num, func) \
|
||||
a = #num; \
|
||||
a = QLatin1StringView(#num); \
|
||||
QVERIFY2(a.func(&ok) == num ## i64 && ok, "Failed: num=" #num ", func=" #func);
|
||||
#else
|
||||
#define TEST_TO_INT(num, func) \
|
||||
a = #num; \
|
||||
a = QLatin1StringView(#num); \
|
||||
QVERIFY2(a.func(&ok) == num ## LL && ok, "Failed: num=" #num ", func=" #func);
|
||||
#endif
|
||||
|
||||
|
|
@ -4023,11 +4023,11 @@ void tst_QString::toNum()
|
|||
|
||||
#if defined (Q_OS_WIN) && defined (Q_CC_MSVC)
|
||||
#define TEST_TO_UINT(num, func) \
|
||||
a = #num; \
|
||||
a = QLatin1StringView(#num); \
|
||||
QVERIFY2(a.func(&ok) == num ## i64 && ok, "Failed: num=" #num ", func=" #func);
|
||||
#else
|
||||
#define TEST_TO_UINT(num, func) \
|
||||
a = #num; \
|
||||
a = QLatin1StringView(#num); \
|
||||
QVERIFY2(a.func(&ok) == num ## ULL && ok, "Failed: num=" #num ", func=" #func);
|
||||
#endif
|
||||
|
||||
|
|
@ -4050,7 +4050,7 @@ void tst_QString::toNum()
|
|||
|
||||
|
||||
#define TEST_BASE(str, base, num) \
|
||||
a = str; \
|
||||
a = QString::fromUtf8(str); \
|
||||
QVERIFY2(a.toInt(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toInt"); \
|
||||
QVERIFY2(a.toUInt(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toUInt"); \
|
||||
QVERIFY2(a.toShort(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toShort"); \
|
||||
|
|
@ -4086,7 +4086,7 @@ void tst_QString::toNum()
|
|||
#undef TEST_BASE
|
||||
|
||||
#define TEST_NEG_BASE(str, base, num) \
|
||||
a = str; \
|
||||
a = QString::fromUtf8(str); \
|
||||
QVERIFY2(a.toInt(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toInt"); \
|
||||
QVERIFY2(a.toShort(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toShort"); \
|
||||
QVERIFY2(a.toLong(&ok, base) == num && ok, "Failed: str=" #str " base= "#base " num=" #num ", func=toLong"); \
|
||||
|
|
@ -4104,7 +4104,7 @@ void tst_QString::toNum()
|
|||
#undef TEST_NEG_BASE
|
||||
|
||||
#define TEST_DOUBLE(num, str) \
|
||||
a = str; \
|
||||
a = QLatin1StringView(str); \
|
||||
QCOMPARE(a.toDouble(&ok), num); \
|
||||
QVERIFY(ok);
|
||||
|
||||
|
|
@ -4117,7 +4117,7 @@ void tst_QString::toNum()
|
|||
|
||||
|
||||
#define TEST_BAD(str, func) \
|
||||
a = str; \
|
||||
a = QLatin1StringView(str); \
|
||||
a.func(&ok); \
|
||||
QVERIFY2(!ok, "Failed: str=" #str " func=" #func);
|
||||
|
||||
|
|
@ -4142,7 +4142,7 @@ void tst_QString::toNum()
|
|||
#undef TEST_BAD
|
||||
|
||||
#define TEST_BAD_ALL(str) \
|
||||
a = str; \
|
||||
a = QString::fromUtf8(str); \
|
||||
a.toShort(&ok); \
|
||||
QVERIFY2(!ok, "Failed: str=" #str); \
|
||||
a.toUShort(&ok); \
|
||||
|
|
@ -4179,11 +4179,11 @@ void tst_QString::toNum()
|
|||
|
||||
#undef TEST_BAD_ALL
|
||||
|
||||
a = "FF";
|
||||
a = u"FF"_s;
|
||||
a.toULongLong(&ok, 10);
|
||||
QVERIFY(!ok);
|
||||
|
||||
a = "FF";
|
||||
a = u"FF"_s;
|
||||
a.toULongLong(&ok, 0);
|
||||
QVERIFY(!ok);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue