diff options
Diffstat (limited to 'tests/auto/qbitarray')
-rw-r--r-- | tests/auto/qbitarray/qbitarray.pro | 4 | ||||
-rw-r--r-- | tests/auto/qbitarray/tst_qbitarray.cpp | 28 |
2 files changed, 27 insertions, 5 deletions
diff --git a/tests/auto/qbitarray/qbitarray.pro b/tests/auto/qbitarray/qbitarray.pro index 182b06a..ec110c6 100644 --- a/tests/auto/qbitarray/qbitarray.pro +++ b/tests/auto/qbitarray/qbitarray.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qbitarray.cpp - - QT = core - - diff --git a/tests/auto/qbitarray/tst_qbitarray.cpp b/tests/auto/qbitarray/tst_qbitarray.cpp index 14a1665..3c9ef53 100644 --- a/tests/auto/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/qbitarray/tst_qbitarray.cpp @@ -43,7 +43,6 @@ #include <QtTest/QtTest> #include <QtCore/QBuffer> #include <QtCore/QDataStream> -#include <iostream> #include "qbitarray.h" @@ -109,6 +108,8 @@ private slots: void invertOnNull() const; void operator_noteq_data(); void operator_noteq(); + + void resize(); }; Q_DECLARE_METATYPE(QBitArray) @@ -629,5 +630,30 @@ void tst_QBitArray::operator_noteq() QCOMPARE(b, res); } +void tst_QBitArray::resize() +{ + // -- check that a resize handles the bits correctly + QBitArray a = QStringToQBitArray(QString("11")); + a.resize(10); + QVERIFY(a.size() == 10); + QCOMPARE( a, QStringToQBitArray(QString("1100000000")) ); + + a.setBit(9); + a.resize(9); + // now the bit in a should have been gone: + QCOMPARE( a, QStringToQBitArray(QString("110000000")) ); + + // grow the array back and check the new bit + a.resize(10); + QCOMPARE( a, QStringToQBitArray(QString("1100000000")) ); + + // other test with and + a.resize(9); + QBitArray b = QStringToQBitArray(QString("1111111111")); + b &= a; + QCOMPARE( b, QStringToQBitArray(QString("1100000000")) ); + +} + QTEST_APPLESS_MAIN(tst_QBitArray) #include "tst_qbitarray.moc" |