summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2022-10-21 16:13:50 +0200
committerAhmad Samir <a.samirh78@gmail.com>2022-11-17 04:15:28 +0200
commitd27360818d78adc412c4fb7012c8d5c0b2f38d98 (patch)
treea9c3095583576aa2c735b36ebc81cbdd07568d7f /tests
parent2ea3d2e924151843b8348871232eb88afb4cfe40 (diff)
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstring/tst_qstring.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp
index 8b9e762d5d..6a40d511e6 100644
--- a/tests/auto/corelib/text/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp
@@ -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()