diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-08-12 09:24:10 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-08-12 09:28:20 (GMT) |
commit | d70d5981c5f07d938c3fbddf3bafc486ef797251 (patch) | |
tree | ac9788bf4ea44727feabae3a8cc8335d32ac326c /tests/auto/qbytearray | |
parent | f28eb5e37c726ecd44bbbf1a5ad746570d2cac9b (diff) | |
download | Qt-d70d5981c5f07d938c3fbddf3bafc486ef797251.zip Qt-d70d5981c5f07d938c3fbddf3bafc486ef797251.tar.gz Qt-d70d5981c5f07d938c3fbddf3bafc486ef797251.tar.bz2 |
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.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 07fdbc3..e3341d1 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) |