refs #214, unit test for BlackSim

This commit is contained in:
Klaus Basan
2014-04-21 11:31:56 +02:00
parent d95c86d094
commit 1cad64fef8
7 changed files with 160 additions and 0 deletions

View File

@@ -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) {

22
tests/blacksim/main.cpp Normal file
View 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;
}

View 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)

View 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

View 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

View 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

View 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