summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbytearray
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-08-12 11:24:10 +0200
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-08-12 11:28:20 +0200
commitd70d5981c5f07d938c3fbddf3bafc486ef797251 (patch)
treeac9788bf4ea44727feabae3a8cc8335d32ac326c /tests/auto/qbytearray
parentf28eb5e37c726ecd44bbbf1a5ad746570d2cac9b (diff)
tst_qbytearray: Auto test for reserve()
This auto test tests undocumented but expected/intuitive behaviour.
Diffstat (limited to 'tests/auto/qbytearray')
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 07fdbc3e62..e3341d1c40 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -142,6 +142,8 @@ private slots:
void repeated_data() const;
void byteRefDetaching() const;
+
+ void reserve();
};
tst_QByteArray::tst_QByteArray()
@@ -1516,6 +1518,22 @@ void tst_QByteArray::byteRefDetaching() const
}
}
+void tst_QByteArray::reserve()
+{
+ int capacity = 100;
+ QByteArray qba;
+ qba.reserve(capacity);
+ QVERIFY(qba.capacity() == capacity);
+ char *data = qba.data();
+
+ // FIXME count from 0 to make it fail
+ for (int i = 1; i < capacity; i++) {
+ qba.resize(i);
+ QVERIFY(capacity == qba.capacity());
+ QVERIFY(data == qba.data());
+ }
+}
+
const char globalChar = '1';
QTEST_APPLESS_MAIN(tst_QByteArray)