Fix unpack for uint values 127 < x < 65536

This commit is contained in:
Manuel Weichselbaumer
2020-04-09 13:01:53 +02:00
parent 7e1ca5b414
commit 8cdf333e5b
2 changed files with 16 additions and 2 deletions

View File

@ -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;