diff options
author | Jamey Hicks <jamey.hicks@nokia.com> | 2011-12-05 17:32:35 -0500 |
---|---|---|
committer | Knoll Lars <lars.knoll@nokia.com> | 2011-12-06 15:29:41 +0100 |
commit | f71f7cefb666469fc91105d63fe23427c460e18c (patch) | |
tree | 9ec05ce3e72ffe1a07758cd5912181a00afef3c0 | |
parent | aa4c52c475d42023da378abba52d695d4c7e5c46 (diff) |
added unit tests for isEmpty().
Change-Id: Iada2bcc02e7410dc740692aa9789f650b79744f1
Reviewed-by: Knoll Lars <lars.knoll@nokia.com>
-rw-r--r-- | tests/auto/tst_qtbinaryjson.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/tst_qtbinaryjson.cpp b/tests/auto/tst_qtbinaryjson.cpp index ad064bf..4b5cb79 100644 --- a/tests/auto/tst_qtbinaryjson.cpp +++ b/tests/auto/tst_qtbinaryjson.cpp @@ -332,6 +332,7 @@ void TestQtBinaryJson::testArrayNestedEmpty() QCOMPARE(value.size(), 0); object.insert("count", 0.); QCOMPARE(object.value("inner").toArray().size(), 0); + QVERIFY(object.value("inner").toArray().isEmpty()); object.data(); QCOMPARE(object.value("inner").toArray().size(), 0); } @@ -340,15 +341,23 @@ void TestQtBinaryJson::testObjectNestedEmpty() { JsonObject object; JsonObject inner; + JsonObject inner2; object.insert("inner", inner); + object.insert("inner2", inner2); JsonObject value = object.value("inner").toObject(); QCOMPARE(value.numKeys(), 0); QCOMPARE(value, inner); QCOMPARE(value.numKeys(), 0); object.insert("count", 0.); QCOMPARE(object.value("inner").toObject().numKeys(), 0); + QCOMPARE(object.value("inner").type(), ObjectValue); object.data(); - QCOMPARE(object.value("inner").toObject().numKeys(), 0); + QVERIFY(object.value("inner").toObject().isEmpty()); + QVERIFY(object.value("inner2").toObject().isEmpty()); + JsonObject reconstituted(JsonObject::fromData(object.data())); + QCOMPARE(reconstituted.value("inner").toObject().numKeys(), 0); + QCOMPARE(reconstituted.value("inner").type(), ObjectValue); + QCOMPARE(reconstituted.value("inner2").type(), ObjectValue); } void TestQtBinaryJson::nullValues() |