summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 585d6afa44..4fb74a2af5 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -1075,18 +1075,25 @@ void tst_QByteArray::toULongLong()
// global function defined in qbytearray.cpp
void tst_QByteArray::qAllocMore()
{
- static const int t[] = {
- INT_MIN, INT_MIN + 1, -1234567, -66000, -1025,
- -3, -1, 0, +1, +3, +1025, +66000, +1234567, INT_MAX - 1, INT_MAX,
- INT_MAX/3
- };
- static const int N = sizeof(t)/sizeof(t[0]);
-
- // make sure qAllocMore() doesn't loop infinitely on any input
- for (int i = 0; i < N; ++i) {
- for (int j = 0; j < N; ++j) {
- ::qAllocMore(t[i], t[j]);
- }
+ using QT_PREPEND_NAMESPACE(qAllocMore);
+
+ // Not very important, but please behave :-)
+ QVERIFY(qAllocMore(0, 0) >= 0);
+
+ for (int i = 1; i < 1 << 8; i <<= 1)
+ QVERIFY(qAllocMore(i, 0) >= i);
+
+ for (int i = 1 << 8; i < 1 << 30; i <<= 1) {
+ const int alloc = qAllocMore(i, 0);
+
+ QVERIFY(alloc >= i);
+ QCOMPARE(qAllocMore(i - 8, 8), alloc - 8);
+ QCOMPARE(qAllocMore(i - 16, 16), alloc - 16);
+ QCOMPARE(qAllocMore(i - 24, 24), alloc - 24);
+ QCOMPARE(qAllocMore(i - 32, 32), alloc - 32);
+
+ QVERIFY(qAllocMore(i - 1, 0) >= i - 1);
+ QVERIFY(qAllocMore(i + 1, 0) >= i + 1);
}
}