mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #214, unit test for BlackSim
This commit is contained in:
@@ -51,6 +51,7 @@ contains(BLACK_CONFIG, Samples) {
|
|||||||
contains(BLACK_CONFIG, Unittests) {
|
contains(BLACK_CONFIG, Unittests) {
|
||||||
SUBDIRS += tests/blackmisc/test_blackmisc.pro
|
SUBDIRS += tests/blackmisc/test_blackmisc.pro
|
||||||
SUBDIRS += tests/blackcore/test_blackcore.pro
|
SUBDIRS += tests/blackcore/test_blackcore.pro
|
||||||
|
SUBDIRS += tests/blacksim/test_blacksim.pro
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(BLACK_CONFIG, Doxygen) {
|
contains(BLACK_CONFIG, Doxygen) {
|
||||||
|
|||||||
22
tests/blacksim/main.cpp
Normal file
22
tests/blacksim/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "testblacksimmain.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace BlackSimTest;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Starter for test cases
|
||||||
|
* \brief main
|
||||||
|
* \param argc
|
||||||
|
* \param argv
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
CBlackSimTestMain::unitMain(argc, argv);
|
||||||
|
Q_UNUSED(a);
|
||||||
|
|
||||||
|
// bye
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
27
tests/blacksim/test_blacksim.pro
Normal file
27
tests/blacksim/test_blacksim.pro
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
include (../../config.pri)
|
||||||
|
include (../../build.pri)
|
||||||
|
|
||||||
|
QT += core testlib dbus network
|
||||||
|
|
||||||
|
TARGET = test_blacksim
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
CONFIG += blackmisc blacksim
|
||||||
|
CONFIG += testcase
|
||||||
|
|
||||||
|
DEPENDPATH += . ../../src
|
||||||
|
INCLUDEPATH += . ../../src
|
||||||
|
|
||||||
|
HEADERS += *.h
|
||||||
|
SOURCES += *.cpp
|
||||||
|
|
||||||
|
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||||
|
../../lib/blacksim.lib
|
||||||
|
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||||
|
../../lib/libblacksim.a
|
||||||
|
|
||||||
|
DESTDIR = ../../bin
|
||||||
|
|
||||||
|
include (../../libraries.pri)
|
||||||
23
tests/blacksim/testblacksimmain.cpp
Normal file
23
tests/blacksim/testblacksimmain.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "testblacksimmain.h"
|
||||||
|
#include "testsimcommon.h"
|
||||||
|
|
||||||
|
namespace BlackSimTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Starting main, equivalent to QTEST_APPLESS_MAIN for multiple test classes.
|
||||||
|
*/
|
||||||
|
int CBlackSimTestMain::unitMain(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
{
|
||||||
|
CTestFsCommon fscommon;
|
||||||
|
status |= QTest::qExec(&fscommon, argc, argv);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
32
tests/blacksim/testblacksimmain.h
Normal file
32
tests/blacksim/testblacksimmain.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIMTEST_TESTMAIN_H
|
||||||
|
#define BLACKSIMTEST_TESTMAIN_H
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
namespace BlackSimTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Class firing all unit tests in this namespace.
|
||||||
|
* Avoids clashes with other main(..) functions and allows to fire the test cases
|
||||||
|
* simply from any other main.
|
||||||
|
*/
|
||||||
|
class CBlackSimTestMain
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief Starting all
|
||||||
|
* \param argc
|
||||||
|
* \param argv
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static int unitMain(int argc, char *argv[]);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
26
tests/blacksim/testsimcommon.cpp
Normal file
26
tests/blacksim/testsimcommon.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "testsimcommon.h"
|
||||||
|
#include "blacksim/simulatorinfo.h"
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
using namespace BlackSim;
|
||||||
|
|
||||||
|
namespace BlackSimTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Tests
|
||||||
|
*/
|
||||||
|
void CTestFsCommon::misc()
|
||||||
|
{
|
||||||
|
CSimulatorInfo si1 = CSimulatorInfo::FSX();
|
||||||
|
CSimulatorInfo si2 = CSimulatorInfo::FS9();
|
||||||
|
CSimulatorInfo si1Copy(si1);
|
||||||
|
QVERIFY2(si1.getValueHash() != si2.getValueHash(), "Info objects expect unequal hashs");
|
||||||
|
QVERIFY2(si1.getValueHash() == si1Copy.getValueHash(), "Info objects expect equal hashs");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
29
tests/blacksim/testsimcommon.h
Normal file
29
tests/blacksim/testsimcommon.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKSIMTEST_TESTSIMCOMMON_H
|
||||||
|
#define BLACKSIMTEST_TESTSIMCOMMON_H
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
namespace BlackSimTest
|
||||||
|
{
|
||||||
|
//! Test for simulator common classes
|
||||||
|
class CTestFsCommon : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Standard test case constructor
|
||||||
|
explicit CTestFsCommon(QObject *parent = nullptr) : QObject(parent) {}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! FsCommon tests
|
||||||
|
void misc();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user