mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-13 00:30:42 +02:00
Merge branch 'feat/compression' into 'master'
added compression with tests See merge request spaceti-app/integrations/common/server-sdk!1
This commit is contained in:
commit
8dd81d9e23
5
common.pri
Normal file
5
common.pri
Normal file
@ -0,0 +1,5 @@
|
||||
SDK_ROOT=$$PWD
|
||||
SDK_TEST_PATH=$$SDK_ROOT/test/data
|
||||
|
||||
DEFINES += SDK_ROOT='\\"$$SDK_ROOT\\"'
|
||||
DEFINES += SDK_TEST_PATH='\\"$$SDK_TEST_PATH\\"'
|
||||
@ -14,7 +14,5 @@ OTHER_FILES += \
|
||||
scripts/* \
|
||||
doc/Doxy* \
|
||||
doc/pages/* \
|
||||
serversdk.pri \
|
||||
serversdkint.pri \
|
||||
*.pri \
|
||||
|
||||
message($$OUT_ROOT)
|
||||
|
||||
@ -23,7 +23,7 @@ SDKDIR=$$ROOT_OUT/src/serversdk
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$SDKDIR/release/ -lserversdk
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SDKDIR/debug/ -lserversdk
|
||||
else:unix: LIBS += -L$$SDKDIR/ -lserversdk
|
||||
else:unix: LIBS += -L$$SDKDIR/ -lserversdk -lz
|
||||
|
||||
|
||||
INCLUDEPATH += $$PWD/src/
|
||||
|
||||
@ -14,6 +14,7 @@ SOURCES += \
|
||||
$$PWD/loggermessage.cpp \
|
||||
$$PWD/requestmanager.cpp \
|
||||
$$PWD/request.cpp \
|
||||
$$PWD/utils.cpp \
|
||||
$$PWD/soaprequest.cpp
|
||||
|
||||
HEADERS += \
|
||||
@ -23,5 +24,7 @@ HEADERS += \
|
||||
$$PWD/loggermessage.h \
|
||||
$$PWD/requestmanager.h \
|
||||
$$PWD/request.h \
|
||||
$$PWD/utils.h \
|
||||
$$PWD/soaprequest.h
|
||||
|
||||
include(../../common.pri)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "compression.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
@ -6,14 +6,14 @@
|
||||
#include <zlib.h> // gzip decompress
|
||||
|
||||
|
||||
namespace core {
|
||||
namespace serversdk {
|
||||
|
||||
/**
|
||||
* @brief Decompress gzip data
|
||||
* @param compressed gzip data
|
||||
* @return decompressed data
|
||||
*/
|
||||
QByteArray Compression::decompress(const QByteArray &compressed)
|
||||
QByteArray Utils::decompress(const QByteArray &compressed)
|
||||
{
|
||||
if (compressed.size() <= 4) {
|
||||
qWarning("gUncompress: Input data is truncated");
|
||||
@ -80,13 +80,10 @@ QByteArray Compression::decompress(const QByteArray &compressed)
|
||||
* @param subpath ( e.g. test/data )
|
||||
* @return absolute path to desired subpath in source folder
|
||||
*/
|
||||
QString Compression::sourcePath(const QString &subpath)
|
||||
QString Utils::sourcePath(const QString &subpath)
|
||||
{
|
||||
QDir dir(__FILE__);
|
||||
dir.cdUp();
|
||||
dir.cdUp();
|
||||
dir.cdUp();
|
||||
|
||||
const QString path = QStringLiteral(SDK_TEST_PATH);
|
||||
QDir dir(path);
|
||||
return dir.absoluteFilePath(subpath);
|
||||
}
|
||||
|
||||
@ -95,7 +92,7 @@ QString Compression::sourcePath(const QString &subpath)
|
||||
* @param subpath ( e.g. test/data/gizp.src )
|
||||
* @return data of file - QByteArray
|
||||
*/
|
||||
QByteArray Compression::sourceData(const QString &subpath)
|
||||
QByteArray Utils::sourceData(const QString &subpath)
|
||||
{
|
||||
// Get data from file
|
||||
QString filePath = sourcePath(subpath);
|
||||
@ -4,9 +4,9 @@
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
namespace core {
|
||||
namespace serversdk {
|
||||
|
||||
class Compression
|
||||
class Utils
|
||||
{
|
||||
public:
|
||||
static QByteArray decompress(const QByteArray &compressed);
|
||||
@ -15,5 +15,4 @@ public:
|
||||
static QByteArray sourceData(const QString &subpath);
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
|
||||
} // namespace serversdk
|
||||
9
test/auto/UtilsTest/UtilsTest.pro
Normal file
9
test/auto/UtilsTest/UtilsTest.pro
Normal file
@ -0,0 +1,9 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_utilstest.cpp
|
||||
41
test/auto/UtilsTest/tst_utilstest.cpp
Normal file
41
test/auto/UtilsTest/tst_utilstest.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||
* Proprietary and confidential
|
||||
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||
*/
|
||||
#include <QtTest>
|
||||
|
||||
// add necessary includes here
|
||||
|
||||
class UtilsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UtilsTest();
|
||||
~UtilsTest();
|
||||
|
||||
private slots:
|
||||
void test_case1();
|
||||
|
||||
};
|
||||
|
||||
UtilsTest::UtilsTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UtilsTest::~UtilsTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UtilsTest::test_case1()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(UtilsTest)
|
||||
|
||||
#include "tst_utilstest.moc"
|
||||
6
test/auto/auto.pro
Normal file
6
test/auto/auto.pro
Normal file
@ -0,0 +1,6 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
basic \
|
||||
unittests \
|
||||
utils
|
||||
11
test/auto/basic/basic.pro
Normal file
11
test/auto/basic/basic.pro
Normal file
@ -0,0 +1,11 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_basictest.cpp
|
||||
|
||||
include(../../../serversdkint.pri)
|
||||
41
test/auto/basic/tst_basictest.cpp
Normal file
41
test/auto/basic/tst_basictest.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||
* Proprietary and confidential
|
||||
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||
*/
|
||||
#include <QtTest>
|
||||
|
||||
// add necessary includes here
|
||||
|
||||
class basicTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
basicTest();
|
||||
~basicTest();
|
||||
|
||||
private slots:
|
||||
void test_case1();
|
||||
|
||||
};
|
||||
|
||||
basicTest::basicTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
basicTest::~basicTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void basicTest::test_case1()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(basicTest)
|
||||
|
||||
#include "tst_basictest.moc"
|
||||
11
test/auto/compress/compress.pro
Normal file
11
test/auto/compress/compress.pro
Normal file
@ -0,0 +1,11 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_decompresstest.cpp
|
||||
|
||||
include(../../../serversdkint.pri)
|
||||
41
test/auto/compress/tst_decompresstest.cpp
Normal file
41
test/auto/compress/tst_decompresstest.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) Filip Bucek - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
||||
* Proprietary and confidential
|
||||
* Written by Filip Bucek <fbucek@invloop.cz>, 2019
|
||||
*/
|
||||
#include <QtTest>
|
||||
|
||||
// add necessary includes here
|
||||
|
||||
class decompressTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
decompressTest();
|
||||
~decompressTest();
|
||||
|
||||
private slots:
|
||||
void test_case1();
|
||||
|
||||
};
|
||||
|
||||
decompressTest::decompressTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
decompressTest::~decompressTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void decompressTest::test_case1()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(decompressTest)
|
||||
|
||||
#include "tst_decompresstest.moc"
|
||||
@ -6,4 +6,4 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
tst_request.h
|
||||
|
||||
include(../../serversdkint.pri)
|
||||
include(../../../serversdkint.pri)
|
||||
56
test/auto/utils/tst_utilstest.cpp
Normal file
56
test/auto/utils/tst_utilstest.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#include "serversdk/utils.h"
|
||||
|
||||
class UtilsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UtilsTest() = default;
|
||||
|
||||
private:
|
||||
Q_SLOT void sourcePathTest();
|
||||
Q_SLOT void sourceDataTest();
|
||||
Q_SLOT void decompresTest();
|
||||
};
|
||||
|
||||
|
||||
|
||||
void UtilsTest::sourcePathTest()
|
||||
{
|
||||
QCOMPARE(serversdk::Utils::sourcePath(""), QStringLiteral(SDK_TEST_PATH));
|
||||
|
||||
QString path = serversdk::Utils::sourcePath("");
|
||||
QFileInfo info(path);
|
||||
QVERIFY(info.exists());
|
||||
}
|
||||
|
||||
|
||||
void UtilsTest::sourceDataTest()
|
||||
{
|
||||
qint32 expected = 895;
|
||||
QByteArray data = serversdk::Utils::sourceData("gzip.src");
|
||||
QCOMPARE(data.count(), expected);
|
||||
}
|
||||
|
||||
void UtilsTest::decompresTest()
|
||||
{
|
||||
QByteArray expectedData = serversdk::Utils::sourceData("gzip.src");
|
||||
int expectedSize = 895;
|
||||
QCOMPARE( expectedData.count(), expectedSize);
|
||||
|
||||
QByteArray compressedData = serversdk::Utils::sourceData("gzip.compressed");
|
||||
int compressedSize = 411;
|
||||
QCOMPARE( compressedData.count(), compressedSize);
|
||||
|
||||
QByteArray decompressedData = serversdk::Utils::decompress(compressedData);
|
||||
|
||||
QCOMPARE(decompressedData.count(), expectedSize);
|
||||
QCOMPARE(decompressedData, expectedData);
|
||||
}
|
||||
|
||||
QTEST_MAIN(UtilsTest)
|
||||
|
||||
#include "tst_utilstest.moc"
|
||||
12
test/auto/utils/utils.pro
Normal file
12
test/auto/utils/utils.pro
Normal file
@ -0,0 +1,12 @@
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
CONFIG += qt console warn_on depend_includepath testcase
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_utilstest.cpp
|
||||
|
||||
include(../../test.pri)
|
||||
|
||||
BIN
test/data/gzip.compressed
Normal file
BIN
test/data/gzip.compressed
Normal file
Binary file not shown.
15
test/data/gzip.src
Normal file
15
test/data/gzip.src
Normal file
@ -0,0 +1,15 @@
|
||||
Příliš žluťoušký kůň
|
||||
compresed using: gzip -c gzip.src > gzip.compressed
|
||||
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
|
||||
<SOAP-ENV:Body>
|
||||
<ns5689:LatLonListSubgrid xmlns:ns5689="uri:DWMLgen">
|
||||
<lowerLeftLatitude xsi:type="xsd:string">35.00</lowerLeftLatitude>
|
||||
<lowerLeftLongitude xsi:type="xsd:string">-82.00</lowerLeftLongitude>
|
||||
<upperRightLatitude xsi:type="xsd:string">35.5</upperRightLatitude>
|
||||
<upperRightLongitude xsi:type="xsd:string">-81.50</upperRightLongitude>
|
||||
<resolution xsi:type="xsd:string">20.0</resolution>
|
||||
</ns5689:LatLonListSubgrid>
|
||||
</SOAP-ENV:Body>
|
||||
</SOAP-ENV:Envelope>
|
||||
3
test/test.pri
Normal file
3
test/test.pri
Normal file
@ -0,0 +1,3 @@
|
||||
include(../common.pri)
|
||||
include(../serversdkint.pri)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
unittests
|
||||
auto \
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user