summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp')
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index fcbe739a39..16884987f4 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -74,6 +74,7 @@ private slots:
void arrayPrepend();
void arrayValueRef_data() { basics_data(); }
void arrayValueRef();
+ void arrayValueRefLargeKey();
void arrayInsertRemove_data() { basics_data(); }
void arrayInsertRemove();
void arrayInsertTagged_data() { basics_data(); }
@@ -1320,6 +1321,30 @@ void tst_QCborValue::arrayValueRef()
iteratorCheck(a.constBegin());
}
+void tst_QCborValue::arrayValueRefLargeKey()
+{
+ // make sure the access via QCborValue & QCborValueRef don't convert this
+ // array to a map
+ constexpr qsizetype LargeKey = 0x10000;
+ QCborArray a;
+ a[LargeKey + 1] = 123;
+
+ QCborValue v(a);
+ QCOMPARE(qAsConst(v)[LargeKey], QCborValue());
+ QCOMPARE(qAsConst(v)[LargeKey + 1], 123);
+ QCOMPARE(v[LargeKey], QCborValue());
+ QCOMPARE(v[LargeKey + 1], 123);
+ QCOMPARE(v.type(), QCborValue::Array);
+
+ QCborArray outer = { QCborValue(a) };
+ QCborValueRef ref = outer[0];
+ QCOMPARE(qAsConst(ref)[LargeKey], QCborValue());
+ QCOMPARE(qAsConst(ref)[LargeKey + 1], 123);
+ QCOMPARE(ref[LargeKey], QCborValue());
+ QCOMPARE(ref[LargeKey + 1], 123);
+ QCOMPARE(ref.type(), QCborValue::Array);
+}
+
void tst_QCborValue::mapValueRef()
{
QFETCH(QCborValue, v);