diff options
Diffstat (limited to 'tests/auto/tst_qtjson.cpp')
-rw-r--r-- | tests/auto/tst_qtjson.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/auto/tst_qtjson.cpp b/tests/auto/tst_qtjson.cpp index bccbcf9..84243d4 100644 --- a/tests/auto/tst_qtjson.cpp +++ b/tests/auto/tst_qtjson.cpp @@ -94,6 +94,7 @@ private Q_SLOTS: void testDuplicateKeys(); void testCompaction(); + void testDebugStream(); }; TestQtJson::TestQtJson(QObject *parent) : QObject(parent) @@ -1153,6 +1154,93 @@ void TestQtJson::testCompaction() QVERIFY(doc.object() == obj); } +void TestQtJson::testDebugStream() +{ + { + // QJsonObject + + QJsonObject object; + QTest::ignoreMessage(QtDebugMsg, "QJsonObject() "); + qDebug() << object; + + object.insert(QLatin1String("foo"), QLatin1String("bar")); + QTest::ignoreMessage(QtDebugMsg, "QJsonObject({\"foo\": \"bar\"}) "); + qDebug() << object; + } + + { + // QJsonArray + + QJsonArray array; + QTest::ignoreMessage(QtDebugMsg, "QJsonArray() "); + qDebug() << array; + + array.append(1); + array.append(QLatin1String("foo")); + QTest::ignoreMessage(QtDebugMsg, "QJsonArray([1,\"foo\"]) "); + qDebug() << array; + } + + { + // QJsonDocument + + QJsonDocument doc; + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument() "); + qDebug() << doc; + + QJsonObject object; + object.insert(QLatin1String("foo"), QLatin1String("bar")); + doc.setObject(object); + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument({\"foo\": \"bar\"}) "); + qDebug() << doc; + + QJsonArray array; + array.append(1); + array.append(QLatin1String("foo")); + QTest::ignoreMessage(QtDebugMsg, "QJsonDocument([1,\"foo\"]) "); + doc.setArray(array); + qDebug() << doc; + } + + { + // QJsonValue + + QJsonValue value; + + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(null) "); + qDebug() << value; + + value = QJsonValue(true); // bool + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(bool, true) "); + qDebug() << value; + + value = QJsonValue((double)4.2); // double + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(number, 4.2) "); + qDebug() << value; + + value = QJsonValue((int)42); // int + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(number, 42) "); + qDebug() << value; + + value = QJsonValue(QLatin1String("foo")); // string + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(string, \"foo\") "); + qDebug() << value; + + QJsonArray array; + array.append(1); + array.append(QLatin1String("foo")); + value = QJsonValue(array); // array + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(array, QJsonArray([1,\"foo\"]) ) "); + qDebug() << value; + + QJsonObject object; + object.insert(QLatin1String("foo"), QLatin1String("bar")); + value = QJsonValue(object); // object + QTest::ignoreMessage(QtDebugMsg, "QJsonValue(object, QJsonObject({\"foo\": \"bar\"}) ) "); + qDebug() << value; + } +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" |