QString: add unittest to verify erase() returns a QString::iterator

Not a const_iterator.

Change-Id: I0a9db7cdd956541e0be6e748b084b502fcc1e563
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Ahmad Samir 2022-10-21 16:13:50 +02:00
parent 2ea3d2e924
commit d27360818d
1 changed files with 10 additions and 0 deletions

View File

@ -3505,6 +3505,16 @@ void tst_QString::erase()
it = s.erase(s.begin(), s.begin() + 1);
QCOMPARE_EQ(s, "b");
QCOMPARE(it, s.begin());
{
QString s1 = QLatin1String("house");
QString copy = s1;
// 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");
}
}
void tst_QString::toNum()