mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-06-25 01:21:33 +02:00
Merge pull request #21 from romixlab/static-build
Static build, tests for QMap, missing export & includes for Windows build
This commit is contained in:
29
qmsgpack.pri
Normal file
29
qmsgpack.pri
Normal file
@ -0,0 +1,29 @@
|
||||
QT += core location
|
||||
|
||||
DEFINES += MSGPACK_MAKE_LIB
|
||||
|
||||
INCLUDEPATH += $$PWD/src
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/src/msgpack.cpp \
|
||||
$$PWD/src/msgpackcommon.cpp \
|
||||
$$PWD/src/private/pack_p.cpp \
|
||||
$$PWD/src/private/unpack_p.cpp \
|
||||
$$PWD/src/private/qt_types_p.cpp \
|
||||
$$PWD/src/msgpackstream.cpp \
|
||||
$$PWD/src/stream/time.cpp \
|
||||
$$PWD/src/stream/geometry.cpp \
|
||||
$$PWD/src/stream/location.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/src/msgpack.h \
|
||||
$$PWD/src/private/pack_p.h \
|
||||
$$PWD/src/private/unpack_p.h \
|
||||
$$PWD/src/endianhelper.h \
|
||||
$$PWD/src/msgpackcommon.h \
|
||||
$$PWD/src/msgpack_export.h \
|
||||
$$PWD/src/private/qt_types_p.h \
|
||||
$$PWD/src/msgpackstream.h \
|
||||
$$PWD/src/stream/location.h \
|
||||
$$PWD/src/stream/time.h \
|
||||
$$PWD/src/stream/geometry.h
|
@ -4,6 +4,12 @@
|
||||
#include <QVariant>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WINRT
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "msgpack_export.h"
|
||||
|
||||
#define MSGPACK_MAJOR 0
|
||||
#define MSGPACK_MINOR 1
|
||||
#define MSGPACK_VERSION 0
|
||||
@ -24,7 +30,7 @@ typedef QVariant (*unpack_user_f)(const QByteArray &data);
|
||||
* @brief version
|
||||
* @return current version
|
||||
*/
|
||||
QString version();
|
||||
MSGPACK_EXPORT QString version();
|
||||
/**
|
||||
* @brief The FirstByte enum
|
||||
* From Message Pack spec
|
||||
|
@ -4,6 +4,12 @@
|
||||
#include <QVariant>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WINRT
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "msgpack_export.h"
|
||||
|
||||
#define MSGPACK_MAJOR @QMSGPACK_MAJOR@
|
||||
#define MSGPACK_MINOR @QMSGPACK_MINOR@
|
||||
#define MSGPACK_VERSION @QMSGPACK_VERSION@
|
||||
@ -24,7 +30,7 @@ typedef QVariant (*unpack_user_f)(const QByteArray &data);
|
||||
* @brief version
|
||||
* @return current version
|
||||
*/
|
||||
QString version();
|
||||
MSGPACK_EXPORT QString version();
|
||||
/**
|
||||
* @brief The FirstByte enum
|
||||
* From Message Pack spec
|
||||
|
@ -13,7 +13,7 @@ CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
LIBS += -lqmsgpack
|
||||
include($$PWD/../../qmsgpack.pri)
|
||||
INCLUDEPATH += ../../src
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ private Q_SLOTS:
|
||||
void test_strings();
|
||||
void test_binary();
|
||||
void test_array();
|
||||
void test_map();
|
||||
};
|
||||
|
||||
|
||||
@ -53,6 +54,18 @@ void UnpackTest::test_integers()
|
||||
QVERIFY(l[17].toULongLong() == std::numeric_limits<quint64>::max());
|
||||
QVERIFY(l[18].toLongLong() == -2147483649);
|
||||
QVERIFY(l[19].toLongLong() == std::numeric_limits<qint64>::min());
|
||||
|
||||
QByteArray pack = MsgPack::pack((qint64)1111111111);
|
||||
qint64 u = MsgPack::unpack(pack).toLongLong();
|
||||
QVERIFY(u == 1111111111);
|
||||
|
||||
pack = MsgPack::pack((qint64)-3333333333);
|
||||
u = MsgPack::unpack(pack).toLongLong();
|
||||
QVERIFY(u == -3333333333);
|
||||
|
||||
pack = MsgPack::pack((qint64)3333333333);
|
||||
u = MsgPack::unpack(pack).toLongLong();
|
||||
QVERIFY(u == 3333333333);
|
||||
}
|
||||
|
||||
void UnpackTest::test_floats()
|
||||
@ -140,6 +153,44 @@ void UnpackTest::test_array()
|
||||
QVERIFY(lu[i] == i);
|
||||
}
|
||||
|
||||
void UnpackTest::test_map()
|
||||
{
|
||||
QVariantMap m;
|
||||
QVariantMap unpacked_m;
|
||||
|
||||
qint64 ll = 339625541;
|
||||
m["ll"] = ll;
|
||||
|
||||
unpacked_m = MsgPack::unpack(MsgPack::pack(m)).toMap();
|
||||
qDebug() << m << "<=>" << unpacked_m;
|
||||
QVERIFY(m == unpacked_m);
|
||||
|
||||
m.clear();
|
||||
ll = 3333642741;
|
||||
m["ll"] = ll;
|
||||
|
||||
QByteArray packArray = MsgPack::pack(m);
|
||||
unpacked_m = MsgPack::unpack(packArray).toMap();
|
||||
qDebug() << m << "<=>" << unpacked_m;
|
||||
QVERIFY(m == unpacked_m);
|
||||
|
||||
m.clear();
|
||||
ll = 33336427413;
|
||||
m["ll"] = ll;
|
||||
|
||||
unpacked_m = MsgPack::unpack(MsgPack::pack(m)).toMap();
|
||||
qDebug() << m << "<=>" << unpacked_m;
|
||||
QVERIFY(m == unpacked_m);
|
||||
|
||||
m.clear();
|
||||
ll = 932838457459459;
|
||||
m["ll"] = ll;
|
||||
|
||||
unpacked_m = MsgPack::unpack(MsgPack::pack(m)).toMap();
|
||||
qDebug() << m << "<=>" << unpacked_m;
|
||||
QVERIFY(m == unpacked_m);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(UnpackTest)
|
||||
|
||||
#include "unpack_test.moc"
|
||||
|
Reference in New Issue
Block a user