mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
Ref T552 Added unittest for QDataStream marshalling.
This commit is contained in:
@@ -9,6 +9,7 @@ SUBDIRS += \
|
||||
simulation \
|
||||
testcompress \
|
||||
testcontainers \
|
||||
testdatastream \
|
||||
testdbus \
|
||||
testicon \
|
||||
testidentifier \
|
||||
|
||||
77
tests/blackmisc/testdatastream/testdatastream.cpp
Normal file
77
tests/blackmisc/testdatastream/testdatastream.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* Copyright (C) 2019
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \ingroup testblackmisc
|
||||
*/
|
||||
|
||||
#include "blackmisc/registermetadata.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackmisc/test/testservice.h"
|
||||
#include "blackmisc/test/testserviceinterface.h"
|
||||
#include "test.h"
|
||||
#include <QTest>
|
||||
#include <QByteArray>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Test;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
//! QDataStream serialization tests
|
||||
class CTestDataStream : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
//! Init test case data
|
||||
void initTestCase();
|
||||
|
||||
//! Test marshaling/unmarshaling
|
||||
void marshalUnmarshal();
|
||||
};
|
||||
|
||||
void CTestDataStream::initTestCase()
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
}
|
||||
|
||||
void CTestDataStream::marshalUnmarshal()
|
||||
{
|
||||
CSimulatedAircraftList testData
|
||||
{
|
||||
{ CCallsign("BAW123"), {}, {} },
|
||||
{ CCallsign("DLH456"), {}, {} },
|
||||
{ CCallsign("AAL789"), {}, {} }
|
||||
};
|
||||
|
||||
QByteArray bytes;
|
||||
{
|
||||
QDataStream writer(&bytes, QIODevice::WriteOnly);
|
||||
writer << testData;
|
||||
}
|
||||
{
|
||||
QDataStream reader(bytes);
|
||||
CSimulatedAircraftList result;
|
||||
reader >> result;
|
||||
QVERIFY2(result == testData, "roundtrip marshal/unmarshal compares equal");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! main
|
||||
BLACKTEST_MAIN(BlackMiscTest::CTestDataStream);
|
||||
|
||||
#include "testdatastream.moc"
|
||||
|
||||
//! \endcond
|
||||
27
tests/blackmisc/testdatastream/testdatastream.pro
Normal file
27
tests/blackmisc/testdatastream/testdatastream.pro
Normal file
@@ -0,0 +1,27 @@
|
||||
load(common_pre)
|
||||
|
||||
QT += core dbus testlib
|
||||
|
||||
TARGET = testdatastream
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += blackconfig
|
||||
CONFIG += blackmisc
|
||||
CONFIG += testcase
|
||||
CONFIG += no_testcase_installs
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
DEPENDPATH += \
|
||||
. \
|
||||
$$SourceRoot/src \
|
||||
$$SourceRoot/tests \
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$SourceRoot/src \
|
||||
$$SourceRoot/tests \
|
||||
|
||||
SOURCES += testdatastream.cpp
|
||||
|
||||
DESTDIR = $$DestRoot/bin
|
||||
|
||||
load(common_post)
|
||||
Reference in New Issue
Block a user