summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-06-08 15:25:26 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-23 14:16:33 +0200
commit796f85b611da5d689e08398e027b130824720a23 (patch)
tree998eecf44a73d6debff1eae10e657a5a8a7d8539 /tests
parent86ae3809a96e298d2e4c643c90417eb01be87fd9 (diff)
Don't operate on bogus data, assert on preconditions instead
QVector::erase shouldn't try to make sense of iterators it doesn't own, so the validation being done here is bogus and dangerous. Instead, it's preferrable to assert, the user needs to ensure proper ownership. The case of erasing an empty sequence is not checked for preconditions to allow QVector v; v.erase(v.begin(), v.end()); , while being stricter on other uses. Autotests were using ill-formed calls to the single argument erase() function on an empty vector and were fixed. This function erases exactly one element, the one pointed to by abegin and require the element exist and be valid. Change-Id: I5f1a6d0d8da072eae0c73a3012620c4ce1065cf0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp8
1 files changed, 0 insertions, 8 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 56570b8e53..09d3051ca5 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -796,16 +796,12 @@ void tst_QVector::eraseEmpty() const
{
{
QVector<T> v;
- v.erase(v.begin());
- QCOMPARE(v.size(), 0);
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
{
QVector<T> v;
v.setSharable(false);
- v.erase(v.begin());
- QCOMPARE(v.size(), 0);
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
@@ -836,8 +832,6 @@ void tst_QVector::eraseEmptyReserved() const
{
QVector<T> v;
v.reserve(10);
- v.erase(v.begin());
- QCOMPARE(v.size(), 0);
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
@@ -845,8 +839,6 @@ void tst_QVector::eraseEmptyReserved() const
QVector<T> v;
v.reserve(10);
v.setSharable(false);
- v.erase(v.begin());
- QCOMPARE(v.size(), 0);
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}