diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 8d09cfa708..18fe85a338 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -3016,8 +3016,7 @@ void tst_QString::append_special_cases() { QString a = "onetwothree"; - while (a.size() - 1) - a.remove(0, 1); + a.erase(a.cbegin(), std::prev(a.cend())); QCOMPARE(a.append(u'b'), QString("eb")); } } @@ -3705,7 +3704,7 @@ void tst_QString::remove_extra() QString s = "BCDEFGHJK"; QString s1 = s; s1.insert(0, u'A'); // detaches - s1.remove(0, 1); + s1.erase(s1.cbegin()); QCOMPARE(s1, s); } diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index f6c97bc345..2265fe3147 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -459,11 +459,13 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) // This code avoids using a QRegExp because QRegExp might be broken. // Sample format: 4,000 msec per iteration (total: 4,000, iterations: 1) - QString sFirstNumber; - while (!remaining.isEmpty() && !remaining.at(0).isSpace()) { - sFirstNumber += remaining.at(0); - remaining.remove(0,1); - } + const auto begin = remaining.cbegin(); + auto it = std::find_if(begin, remaining.cend(), [](const auto ch) { + return ch.isSpace(); + }); + QString sFirstNumber{std::distance(begin, it), Qt::Uninitialized}; + std::move(begin, it, sFirstNumber.begin()); + remaining.erase(begin, it); remaining = remaining.trimmed(); // 4,000 -> 4000