swift
Loading...
Searching...
No Matches
testdatastream.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
10
11#include <QByteArray>
12#include <QTest>
13
14#include "test.h"
15
20
21using namespace swift::misc;
22using namespace swift::misc::aviation;
23using namespace swift::misc::simulation;
24using namespace swift::misc::test;
25
26namespace MiscTest
27{
29 class CTestDataStream : public QObject
30 {
32
33 private slots:
35 void initTestCase();
36
38 void marshalUnmarshal();
39 };
40
41 void CTestDataStream::initTestCase() { swift::misc::registerMetadata(); }
42
43 void CTestDataStream::marshalUnmarshal()
44 {
45 CSimulatedAircraftList testData { { CCallsign("BAW123"), {}, {} },
46 { CCallsign("DLH456"), {}, {} },
47 { CCallsign("AAL789"), {}, {} } };
48
49 QByteArray bytes;
50 {
51 QDataStream writer(&bytes, QIODevice::WriteOnly);
52 writer << testData;
53 }
54 {
55 QDataStream reader(bytes);
56 CSimulatedAircraftList result;
57 reader >> result;
58 QVERIFY2(result == testData, "roundtrip marshal/unmarshal compares equal");
59 }
60 }
61} // namespace MiscTest
62
65
66#include "testdatastream.moc"
67
QDataStream serialization tests.
Value object encapsulating information of a callsign.
Definition callsign.h:30
Value object encapsulating a list of aircraft.
Generate data for testing purposes.
Definition testdata.h:45
Free functions in swift::misc.
void registerMetadata()
Register all relevant metadata in Misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QVERIFY2(condition, message)
#define SWIFTTEST_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject including instantiating a QCoreApp...
Definition test.h:57