diff --git a/client.pro b/client.pro index 7cfe5c785..43087006d 100644 --- a/client.pro +++ b/client.pro @@ -51,6 +51,7 @@ contains(BLACK_CONFIG, Samples) { contains(BLACK_CONFIG, Unittests) { SUBDIRS += tests/blackmisc/test_blackmisc.pro SUBDIRS += tests/blackcore/test_blackcore.pro + SUBDIRS += tests/blacksim/test_blacksim.pro } contains(BLACK_CONFIG, Doxygen) { diff --git a/tests/blacksim/main.cpp b/tests/blacksim/main.cpp new file mode 100644 index 000000000..de7b30961 --- /dev/null +++ b/tests/blacksim/main.cpp @@ -0,0 +1,22 @@ +#include "testblacksimmain.h" +#include +#include + +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; +} diff --git a/tests/blacksim/test_blacksim.pro b/tests/blacksim/test_blacksim.pro new file mode 100644 index 000000000..7ab5faff3 --- /dev/null +++ b/tests/blacksim/test_blacksim.pro @@ -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) diff --git a/tests/blacksim/testblacksimmain.cpp b/tests/blacksim/testblacksimmain.cpp new file mode 100644 index 000000000..fbbdd59e5 --- /dev/null +++ b/tests/blacksim/testblacksimmain.cpp @@ -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 diff --git a/tests/blacksim/testblacksimmain.h b/tests/blacksim/testblacksimmain.h new file mode 100644 index 000000000..9a9d79115 --- /dev/null +++ b/tests/blacksim/testblacksimmain.h @@ -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 + +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 diff --git a/tests/blacksim/testsimcommon.cpp b/tests/blacksim/testsimcommon.cpp new file mode 100644 index 000000000..a2b9aef60 --- /dev/null +++ b/tests/blacksim/testsimcommon.cpp @@ -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 + +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 diff --git a/tests/blacksim/testsimcommon.h b/tests/blacksim/testsimcommon.h new file mode 100644 index 000000000..869635f15 --- /dev/null +++ b/tests/blacksim/testsimcommon.h @@ -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 + +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