summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvarlengtharray
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2012-09-27 10:11:24 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 21:13:52 +0200
commit47d635b011f55a7386befb7247c56d1a6e6b2f05 (patch)
treed4e6c90c4aeac4f5e867e4ffc9bad191b9519b42 /tests/auto/corelib/tools/qvarlengtharray
parent171c638a89c64cd421c44556c422f4cef2596fab (diff)
Test: Split tst_QVarLengthArray::oldTests
The entire test is currently skipped while only the last part is causing problems. Move the out of memory test code to its own test function and skip only this function with the appropriate bug number. By allocating too much memory this test is causing a crash. Task-number: QTBUG-27361 Task-number: QTBUG-22342 Change-Id: Ia308099b7f12cf2c567b62063a7bbcc6fb38515b Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qvarlengtharray')
-rw-r--r--tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp94
1 files changed, 48 insertions, 46 deletions
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
index 05219ab95a..21e8c36081 100644
--- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -58,6 +58,7 @@ private slots:
void count();
void first();
void last();
+ void outOfMemory();
};
int fooCtor = 0;
@@ -198,53 +199,54 @@ void tst_QVarLengthArray::oldTests()
QVarLengthArray<int> sa3(sa);
QCOMPARE(sa3[5], 5);
}
+}
- QSKIP("This test causes the machine to crash when allocating too much memory.");
- {
- QVarLengthArray<Foo> a;
- const int N = 0x7fffffff / sizeof(Foo);
- const int Prealloc = a.capacity();
- const Foo *data0 = a.constData();
-
- a.resize(N);
- if (a.size() == N) {
- QVERIFY(a.capacity() >= N);
- QCOMPARE(fooCtor, N);
- QCOMPARE(fooDtor, 0);
-
- for (int i = 0; i < N; i += 35000)
- a[i] = Foo();
- } else {
- // this is the case we're actually testing
- QCOMPARE(a.size(), 0);
- QCOMPARE(a.capacity(), Prealloc);
- QCOMPARE(a.constData(), data0);
- QCOMPARE(fooCtor, 0);
- QCOMPARE(fooDtor, 0);
-
- a.resize(5);
- QCOMPARE(a.size(), 5);
- QCOMPARE(a.capacity(), Prealloc);
- QCOMPARE(a.constData(), data0);
- QCOMPARE(fooCtor, 5);
- QCOMPARE(fooDtor, 0);
-
- a.resize(Prealloc + 1);
- QCOMPARE(a.size(), Prealloc + 1);
- QVERIFY(a.capacity() >= Prealloc + 1);
- QVERIFY(a.constData() != data0);
- QCOMPARE(fooCtor, Prealloc + 6);
- QCOMPARE(fooDtor, 5);
-
- const Foo *data1 = a.constData();
-
- a.resize(0x10000000);
- QCOMPARE(a.size(), 0);
- QVERIFY(a.capacity() >= Prealloc + 1);
- QVERIFY(a.constData() == data1);
- QCOMPARE(fooCtor, Prealloc + 6);
- QCOMPARE(fooDtor, Prealloc + 6);
- }
+void tst_QVarLengthArray::outOfMemory()
+{
+ QSKIP("QTBUG-27361");
+ QVarLengthArray<Foo> a;
+ const int N = 0x7fffffff / sizeof(Foo);
+ const int Prealloc = a.capacity();
+ const Foo *data0 = a.constData();
+
+ a.resize(N);
+ if (a.size() == N) {
+ QVERIFY(a.capacity() >= N);
+ QCOMPARE(fooCtor, N);
+ QCOMPARE(fooDtor, 0);
+
+ for (int i = 0; i < N; i += 35000)
+ a[i] = Foo();
+ } else {
+ // this is the case we're actually testing
+ QCOMPARE(a.size(), 0);
+ QCOMPARE(a.capacity(), Prealloc);
+ QCOMPARE(a.constData(), data0);
+ QCOMPARE(fooCtor, 0);
+ QCOMPARE(fooDtor, 0);
+
+ a.resize(5);
+ QCOMPARE(a.size(), 5);
+ QCOMPARE(a.capacity(), Prealloc);
+ QCOMPARE(a.constData(), data0);
+ QCOMPARE(fooCtor, 5);
+ QCOMPARE(fooDtor, 0);
+
+ a.resize(Prealloc + 1);
+ QCOMPARE(a.size(), Prealloc + 1);
+ QVERIFY(a.capacity() >= Prealloc + 1);
+ QVERIFY(a.constData() != data0);
+ QCOMPARE(fooCtor, Prealloc + 6);
+ QCOMPARE(fooDtor, 5);
+
+ const Foo *data1 = a.constData();
+
+ a.resize(0x10000000);
+ QCOMPARE(a.size(), 0);
+ QVERIFY(a.capacity() >= Prealloc + 1);
+ QVERIFY(a.constData() == data1);
+ QCOMPARE(fooCtor, Prealloc + 6);
+ QCOMPARE(fooDtor, Prealloc + 6);
}
}