From 679a4e98c76f0952aab4a09b8bf0ce8f759d4383 Mon Sep 17 00:00:00 2001 From: Leonard Lee Date: Mon, 1 Oct 2012 15:32:44 +0200 Subject: Fix #if 0 usage in collections autotest. Removed inappropriate use of #if 0 in collections autotest. Task-number: QTBUG-22471 Change-Id: Ibf4e5fae8e671ebfd0dc5734875fcc8879b330af Reviewed-by: Thiago Macieira --- tests/auto/other/collections/tst_collections.cpp | 42 +++++++++++------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'tests/auto/other') diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 940b651291..c4d5d9dabd 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -1013,12 +1013,9 @@ void tst_Collections::vector() QVERIFY(v1 + v2 == v3); QVector emptyVector; + // emptyVector.remove(3, -3); // Q_ASSERT_X() triggered with "index out of range" message. QCOMPARE(emptyVector.size(), 0); -#if 0 - // this should trigger an assert - emptyVector.remove(3, -3); - QCOMPARE(emptyVector.size(), 0); -#endif + emptyVector.remove(0, 0); QCOMPARE(emptyVector.size(), 0); @@ -1318,19 +1315,22 @@ void tst_Collections::byteArray() QVERIFY(hello.mid(hello.size()-2) == "lo"); QVERIFY(hello.mid(hello.size()-200) == "hello"); - QByteArray null; - QByteArray nonNull = ""; - QVERIFY(null.left(10).isNull()); - QVERIFY(null.mid(0).isNull()); + QByteArray nullByteArray; + QByteArray nonNullByteArray = ""; + QVERIFY(nullByteArray.left(10).isNull()); + QVERIFY(nullByteArray.mid(0).isNull()); -#if 0 - QVERIFY(null == QByteArray::null); - QVERIFY(QByteArray::null == null); - QVERIFY(nonNull != QByteArray::null); - QVERIFY(QByteArray::null != nonNull); - QVERIFY(null == nonNull); - QVERIFY(QByteArray::null == QByteArray::null); -#endif + QVERIFY(nullByteArray.isEmpty() == nonNullByteArray.isEmpty()); + QVERIFY(nullByteArray.size() == nonNullByteArray.size()); + + QVERIFY(nullByteArray == QByteArray()); // QByteArray() is both null and empty. + QVERIFY(QByteArray() == nullByteArray); + + QVERIFY(nonNullByteArray == QByteArray("")); // QByteArray("") is empty, but not null. + QVERIFY(QByteArray("") == nonNullByteArray); + + QVERIFY(nullByteArray == nonNullByteArray); + QVERIFY(QByteArray() == QByteArray("")); QByteArray str = "Hello"; QByteArray cstr(str.data(), str.size()); @@ -2170,13 +2170,11 @@ void tst_Collections::qstring() s = s.arg("foo").arg(7); QVERIFY(s == "(foo)(7)"); - -#if 0 s = "stl rocks"; - std::string stl_string = s; - s = stl_string; + std::string stl_string = s.toStdString(); // TODO: std::string stl_string = s does not work. + QVERIFY(s == "stl rocks"); + s = QString::fromStdString(stl_string); // TODO: s = stl_string does not work. QVERIFY(s == "stl rocks"); -#endif { QString str("Bananas"); -- cgit v1.2.3