diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-03-20 13:05:43 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-12-22 10:00:46 +0000 |
commit | 26237f0a2d8db80024b601f676bbce54d483e672 (patch) | |
tree | b22451de1ad84676acdd1011eed1b3a0d95a7307 /tests | |
parent | 2e1de7f3c4cab55ce6b65f945cf0f444e6bee53a (diff) |
Fix QJsonValue::fromVariant() if the variant contains a json object
If the variant contains a known json type (value, array, object or
document), simply unwrap those. In the case of the json document
wrap the contained object/array into a QJsonValue.
This should be the expected behavior, and makes more sense than
returning a null QJsonValue.
Task-number: QTBUG-41234
Change-Id: Id084fc11220d51aaf78b7694fd0ebef1411f5c51
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/json/tst_qtjson.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 884c4b3850..1665ff696d 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1137,6 +1137,12 @@ void tst_QtJson::fromVariant() QCOMPARE(QJsonValue::fromVariant(QVariant(stringList)), QJsonValue(jsonArray_string)); QCOMPARE(QJsonValue::fromVariant(QVariant(variantList)), QJsonValue(jsonArray_variant)); QCOMPARE(QJsonValue::fromVariant(QVariant(variantMap)), QJsonValue(jsonObject)); + + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonValue(true))).isBool()); + QVERIFY(QJsonValue::fromVariant(QVariant(jsonArray_string)).isArray()); + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonDocument(jsonArray_string))).isArray()); + QVERIFY(QJsonValue::fromVariant(QVariant(jsonObject)).isObject()); + QVERIFY(QJsonValue::fromVariant(QVariant(QJsonDocument(jsonObject))).isObject()); } void tst_QtJson::fromVariantMap() |