summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2019-11-26 07:21:55 -0800
committerThiago Macieira <thiago.macieira@intel.com>2019-12-05 07:59:07 -0800
commit1f592da7f175aa75726eece2fab8f5c1edde193f (patch)
treedde433457546250a471333cf27cff9a1d6b6311e /tests/auto
parent455e9e5be35b36d79b9541a6e014c5c9026d685b (diff)
QCborValue: fix replacing of elements with byte data with ones without
We forgot to reset the flags when replacing the element, so we ended up with an integer with HasByteData after: testMap[0] = QStringLiteral("value"); testMap[0] = 42; Fixes: QTBUG-80342 Change-Id: Ia2aa807ffa8a4c798425fffd15dabfa066ea84b0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 47ad328d64..8deb780dd0 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -821,9 +821,37 @@ void tst_QCborValue::mapMutation()
QVERIFY(v.isUndefined());
// now mutate the list
+ // simple -> HasByteData
+ const QString strValue = QStringLiteral("value");
+ v = strValue;
+ QVERIFY(v.isString());
+ QCOMPARE(v, QCborValue(strValue));
+ QCOMPARE(m, QCborMap({{42, strValue}}));
+
+ // HasByteData -> HasByteData
+ const QLatin1String otherStrValue("othervalue");
+ v = otherStrValue;
+ QVERIFY(v.isString());
+ QCOMPARE(v, QCborValue(otherStrValue));
+ QCOMPARE(m, QCborMap({{42, otherStrValue}}));
+
+ // HasByteData -> simple
+ v = 42;
+ QVERIFY(v.isInteger());
+ QCOMPARE(v, QCborValue(42));
+ QCOMPARE(m, QCborMap({{42, 42}}));
+
+ // simple -> container
+ v = QCborArray{1, 2, 3};
+ QVERIFY(v.isArray());
+ QCOMPARE(v, QCborArray({1, 2, 3}));
+ QCOMPARE(m, QCborMap({{42, QCborArray{1, 2, 3}}}));
+
+ // container -> simple
v = true;
QVERIFY(v.isBool());
QVERIFY(v.isTrue());
+ QCOMPARE(m, QCborMap({{42, true}}));
QVERIFY(m.begin()->isTrue());
QVERIFY(m.begin().value() == v);
QVERIFY(v == m.begin().value());