summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@nokia.com>2012-03-20 07:07:03 +0100
committerQt by Nokia <qt-info@nokia.com>2012-05-06 15:32:45 +0200
commit54d9fd61e13f7369c831ab76503f7619d60c0cfd (patch)
treeb8931b56e581773c9538ce0a1278342d1e88042d /tests
parentd6bb52b1961fcd93d301fa91d4284d45b17b8844 (diff)
Add default value for getters in QJsonValue
Done-with: Debao Zhang <dbzhang800@gmail.com> Change-Id: I3ddd8dd89dc75d91ac9977bf9b6eb3174d7669e4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index bf6a58a24b..73b79b1607 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -154,6 +154,12 @@ void TestQtJson::cleanup()
void TestQtJson::testValueSimple()
{
+ QJsonObject object;
+ object.insert("number", 999.);
+ QJsonArray array;
+ for (int i = 0; i < 10; ++i)
+ array.append((double)i);
+
QJsonValue value(true);
QCOMPARE(value.type(), QJsonValue::Bool);
QCOMPARE(value.toDouble(), 0.);
@@ -161,12 +167,17 @@ void TestQtJson::testValueSimple()
QCOMPARE(value.toBool(), true);
QCOMPARE(value.toObject(), QJsonObject());
QCOMPARE(value.toArray(), QJsonArray());
+ QCOMPARE(value.toDouble(99.), 99.);
+ QCOMPARE(value.toString(QString("test")), QString("test"));
+ QCOMPARE(value.toObject(object), object);
+ QCOMPARE(value.toArray(array), array);
value = 999.;
QCOMPARE(value.type(), QJsonValue::Double);
QCOMPARE(value.toDouble(), 999.);
QCOMPARE(value.toString(), QString());
QCOMPARE(value.toBool(), false);
+ QCOMPARE(value.toBool(true), true);
QCOMPARE(value.toObject(), QJsonObject());
QCOMPARE(value.toArray(), QJsonArray());
@@ -190,7 +201,6 @@ void TestQtJson::testValueSimple()
QCOMPARE(value.toBool(), false);
QCOMPARE(value.toObject(), QJsonObject());
QCOMPARE(value.toArray(), QJsonArray());
-
}
void TestQtJson::testNumbers()