Fix unpack for uint values 127 < x < 65536
This commit is contained in:
1 parent
7e1ca5b414
commit
8cdf333e5b
2 files changed
+16
-2
No files matched your search
@@ -10,6 +10,7 @@ class MixedTest : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void test_uint();
|
||||
void test_float();
|
||||
void test_double();
|
||||
void test_map();
|
||||
@@ -17,6 +18,19 @@ private Q_SLOTS:
|
||||
void test_mixed();
|
||||
};
|
||||
|
||||
void MixedTest::test_uint()
|
||||
{
|
||||
for (int i = 0; i <= 32; ++i) {
|
||||
const quint32 u = (0x1UL<<i) - 1;
|
||||
QByteArray packed = MsgPack::pack(u);
|
||||
QVariant unpacked = MsgPack::unpack(packed);
|
||||
QVERIFY2(unpacked.type() == QVariant::Type::UInt,
|
||||
qPrintable(QString("Unpack failed for value %1. Type is %2").arg(u).arg(unpacked.type())));
|
||||
QVERIFY2(unpacked.toUInt() == u,
|
||||
qPrintable(QString("Unpack failed for value %1. Type is %2").arg(u).arg(unpacked.type())));
|
||||
}
|
||||
}
|
||||
|
||||
void MixedTest::test_float()
|
||||
{
|
||||
float f;
|
||||
|
||||
Reference in new issue
Block a user