mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
|
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
|
|
|
//! \cond PRIVATE_TESTS
|
|
|
|
/*!
|
|
* \file
|
|
* \ingroup testmisc
|
|
*/
|
|
|
|
#include "misc/registermetadata.h"
|
|
#include "misc/simulation/simulatedaircraftlist.h"
|
|
#include "misc/test/testservice.h"
|
|
#include "misc/test/testserviceinterface.h"
|
|
#include "test.h"
|
|
#include <QTest>
|
|
#include <QByteArray>
|
|
|
|
using namespace swift::misc;
|
|
using namespace swift::misc::aviation;
|
|
using namespace swift::misc::simulation;
|
|
using namespace swift::misc::test;
|
|
|
|
namespace MiscTest
|
|
{
|
|
//! 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()
|
|
{
|
|
swift::misc::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
|
|
SWIFTTEST_MAIN(MiscTest::CTestDataStream);
|
|
|
|
#include "testdatastream.moc"
|
|
|
|
//! \endcond
|