Fix #if 0 usage in collections autotest.
authorLeonard Lee <leonard.lee@digia.com>
Mon, 1 Oct 2012 13:32:44 +0000 (15:32 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 4 Oct 2012 01:03:17 +0000 (03:03 +0200)
Removed inappropriate use of #if 0 in collections autotest.

Task-number: QTBUG-22471
Change-Id: Ibf4e5fae8e671ebfd0dc5734875fcc8879b330af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
tests/auto/other/collections/tst_collections.cpp

index 940b651..c4d5d9d 100644 (file)
@@ -1013,12 +1013,9 @@ void tst_Collections::vector()
     QVERIFY(v1 + v2 == v3);
 
     QVector<int> 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");