mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-08-01 03:14:27 +02:00
Nil packer and unittests pack/unpack for nil
This commit is contained in:
@@ -9,6 +9,7 @@ class PackTest : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void test_nil();
|
||||
void test_bool();
|
||||
void test_fixint();
|
||||
void test_integer8();
|
||||
@@ -21,6 +22,14 @@ private Q_SLOTS:
|
||||
void test_array();
|
||||
};
|
||||
|
||||
void PackTest::test_nil()
|
||||
{
|
||||
QByteArray arr = MsgPack::pack(QVariant());
|
||||
quint8 *p = (quint8 *)arr.data();
|
||||
QVERIFY(arr.size() == 1);
|
||||
QVERIFY(p[0] == 0xc0);
|
||||
}
|
||||
|
||||
void PackTest::test_bool()
|
||||
{
|
||||
QByteArray arr = MsgPack::pack(false);
|
||||
|
@@ -9,6 +9,7 @@ class UnpackTest : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void test_nil();
|
||||
void test_booleans();
|
||||
void test_integers();
|
||||
void test_floats();
|
||||
@@ -17,6 +18,13 @@ private Q_SLOTS:
|
||||
void test_array();
|
||||
};
|
||||
|
||||
void UnpackTest::test_nil()
|
||||
{
|
||||
QByteArray pack = MsgPack::pack(QVariantList() << true << QVariant());
|
||||
QVariantList u = MsgPack::unpack(pack).toList();
|
||||
QVERIFY(u[0] == true);
|
||||
QVERIFY(u[1].isNull());
|
||||
}
|
||||
|
||||
void UnpackTest::test_booleans()
|
||||
{
|
||||
|
Reference in New Issue
Block a user