diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-01-25 15:25:35 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-04 03:04:17 +0000 |
commit | fcb0f68e77bb69544f0ae310baffd3ceff8a9e5d (patch) | |
tree | afd7fe27c11d39d12c3bc2d0eefd385e55081589 /tests/auto/corelib/serialization | |
parent | 6c64a9b2d29d5de054d1d8ccec2050c28767c10c (diff) |
CBOR: Complete the conversions between CBOR, JSON and Qt meta types
Change-Id: I56b444f9d6274221a3b7fffd150d3130db6ef1a0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/serialization')
-rw-r--r-- | tests/auto/corelib/serialization/qcborvalue_json/tst_qcborvalue_json.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/serialization/qcborvalue_json/tst_qcborvalue_json.cpp b/tests/auto/corelib/serialization/qcborvalue_json/tst_qcborvalue_json.cpp index 324e9b1dfb..ad4c48450a 100644 --- a/tests/auto/corelib/serialization/qcborvalue_json/tst_qcborvalue_json.cpp +++ b/tests/auto/corelib/serialization/qcborvalue_json/tst_qcborvalue_json.cpp @@ -151,6 +151,12 @@ void tst_QCborValue_Json::toVariant() } QCOMPARE(v.toVariant(), variant); + if (variant.isValid()) { + QVariant variant2 = QVariant::fromValue(v); + QVERIFY(variant2.canConvert(variant.userType())); + QVERIFY(variant2.convert(variant.userType())); + QCOMPARE(variant2, variant); + } // tags get ignored: QCOMPARE(QCborValue(QCborKnownTags::Signature, v).toVariant(), variant); @@ -174,6 +180,7 @@ void tst_QCborValue_Json::toJson() QFETCH(QJsonValue, json); QCOMPARE(v.toJsonValue(), json); + QCOMPARE(QVariant::fromValue(v).toJsonValue(), json); // most tags get ignored: QCOMPARE(QCborValue(QCborKnownTags::Signature, v).toJsonValue(), json); @@ -216,6 +223,7 @@ void tst_QCborValue_Json::fromVariant() QFETCH(QVariant, variant); QCOMPARE(QCborValue::fromVariant(variant), v); + QCOMPARE(variant.value<QCborValue>(), v); // try arrays QCOMPARE(QCborArray::fromVariantList({variant}), QCborArray{v}); @@ -260,6 +268,7 @@ void tst_QCborValue_Json::fromJson() QFETCH(QJsonValue, json); QCOMPARE(QCborValue::fromJsonValue(json), v); + QCOMPARE(QVariant(json).value<QCborValue>(), v); QCOMPARE(QCborArray::fromJsonArray({json}), QCborArray({v})); QCOMPARE(QCborArray::fromJsonArray({json, json}), QCborArray({v, v})); QCOMPARE(QCborMap::fromJsonObject({{"foo", json}}), QCborMap({{"foo", v}})); |