refs #432, unit test for originator, in same step cleaned unit test code a bit (headers, ...)

This commit is contained in:
Klaus Basan
2015-05-28 19:51:34 +02:00
parent d8d0eca3d8
commit eb8b6e6f1f
11 changed files with 183 additions and 108 deletions

View File

@@ -1,13 +1,15 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#ifndef BLACKMISCTEST_H
#define BLACKMISCTEST_H
/*! \file */
/*!
* @namespace BlackMiscTest
* Unit tests for BlackMisc. Unit tests do have their own namespace, so

View File

@@ -1,9 +1,13 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
/*! \file */
//! \file
#ifndef BLACKMISCTEST_TESTAVIATIONBASE_H
#define BLACKMISCTEST_TESTAVIATIONBASE_H
@@ -13,44 +17,29 @@
namespace BlackMiscTest
{
/*!
* \brief Aviation classes basic tests
*/
//! Aviation classes basic tests
class CTestAviation : public QObject
{
Q_OBJECT
public:
/*!
* \brief Standard test case constructor
* \param parent
*/
//! Standard test case constructor
explicit CTestAviation(QObject *parent = nullptr);
private slots:
/*!
* \brief Basic unit tests for physical units
*/
//! Basic unit tests for physical units
void headingBasics();
/*!
* \brief COM and NAV units
*/
//! COM and NAV units
void comAndNav();
/*!
* \brief Transponder
*/
//! Transponder
void transponder();
/*!
* \brief Callsigns // callsign containers
*/
//! Callsigns and callsign containers
void callsignWithContainers();
/*!
* \brief Testing copying and equality of objects
*/
//! Testing copying and equality of objects
void copyAndEqual();
};

View File

@@ -6,6 +6,7 @@
#include "testphysicalquantities.h"
#include "testaviation.h"
#include "testgeo.h"
#include "testoriginator.h"
#include "testcontainers.h"
#include "testvariantandmap.h"
#include "testhardware.h"
@@ -26,9 +27,11 @@ namespace BlackMiscTest
CTestContainers containerTests;
CTestVariantAndMap variantAndMap;
CTestHardware hardwareTests;
CTestOriginator originatorTests;
status |= QTest::qExec(&pqBaseTests, argc, argv);
status |= QTest::qExec(&avBaseTests, argc, argv);
status |= QTest::qExec(&geoTests, argc, argv);
status |= QTest::qExec(&originatorTests, argc, argv);
status |= QTest::qExec(&containerTests, argc, argv);
status |= QTest::qExec(&variantAndMap, argc, argv);
status |= QTest::qExec(&hardwareTests, argc, argv);

View File

@@ -1,7 +1,11 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#ifndef BLACKMISCTEST_TESTMAIN_H
#define BLACKMISCTEST_TESTMAIN_H
@@ -11,20 +15,13 @@
namespace BlackMiscTest
{
/*!
* 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 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 CBlackMiscTestMain
{
public:
/*!
* \brief Starting all
* \param argc
* \param argv
* \return
*/
//! Starting all
static int unitMain(int argc, char *argv[]);
};
}

View File

@@ -1,9 +1,13 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
/*! \file */
//! \file
#ifndef BLACKMISCTEST_TESTGEO_H
#define BLACKMISCTEST_TESTGEO_H
@@ -13,26 +17,19 @@
namespace BlackMiscTest
{
/*!
* \brief Geo classes tests
*/
class CTestGeo : public QObject
{
Q_OBJECT
//! Geo classes tests
class CTestGeo : public QObject
{
Q_OBJECT
public:
/*!
* \brief Standard test case constructor
* \param parent
*/
explicit CTestGeo(QObject *parent = 0) : QObject(parent) {}
public:
//! Standard test case constructor
explicit CTestGeo(QObject *parent = nullptr) : QObject(parent) {}
private slots:
/*!
* \brief Basic unit tests for geo classes
*/
void geoBasics();
};
private slots:
//! Basic unit tests for geo classes
void geoBasics();
};
} // namespace

View File

@@ -1,37 +1,36 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISCTEST_TESTHARDWARE_H
#define BLACKMISCTEST_TESTHARDWARE_H
#include <QtTest/QtTest>
namespace BlackMiscTest
{
/*!
* \brief Hardware classes basic tests
*/
//! Hardware classes basic tests
class CTestHardware : public QObject
{
Q_OBJECT
public:
/*!
* \brief Standard test case constructor
* \param parent
*/
//! Standard test case constructor
explicit CTestHardware(QObject *parent = nullptr);
signals:
private slots:
//! \brief CKeyboardKey basic tests
//! CKeyboardKey basic tests
void keyboardKey();
};
} // namespace BlackMiscTest
} // namespace
#endif // BLACKMISCTEST_TESTHARDWARE_H
#endif // guard

View File

@@ -0,0 +1,41 @@
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#include "testoriginator.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/originatorlist.h"
using namespace BlackMisc;
namespace BlackMiscTest
{
void CTestOriginator::originatorBasics()
{
COriginator o1;
COriginator o2;
COriginator o3("foobar");
QVERIFY2(o1 == o2, "Two default originators shall be equal");
QVERIFY2(o1 != o3, "Those originators shall be unequal");
// test object name change
QObject q;
q.setObjectName("foo");
CTestOriginatorAware oa(&q);
QVERIFY2(oa.originator().getName() == q.objectName(), "Names shall be equal");
q.setObjectName("bar");
QVERIFY2(oa.originator().getName() == q.objectName(), "Names shall be equal");
}
CTestOriginatorAware::CTestOriginatorAware(QObject *nameObject) : COriginatorAware(nameObject)
{ }
} //namespace

View File

@@ -0,0 +1,43 @@
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISCTEST_TESTORIGINATOR_H
#define BLACKMISCTEST_TESTORIGINATOR_H
#include "blackmisc/originatoraware.h"
#include <QtTest/QtTest>
namespace BlackMiscTest
{
//! Testing orignator
class CTestOriginator : public QObject
{
Q_OBJECT
public:
//! Constructor
explicit CTestOriginator(QObject *parent = nullptr) : QObject(parent) {}
private slots:
void originatorBasics();
};
//! Test originator aware
class CTestOriginatorAware : public BlackMisc::COriginatorAware
{
public:
//! Constructor
CTestOriginatorAware(QObject *nameObject);
};
} // namespace
#endif // guard

View File

@@ -1,7 +1,13 @@
/* 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/. */
/* Copyright (C) 2014
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H
#define BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H
@@ -11,10 +17,7 @@
namespace BlackMiscTest
{
/*!
* \brief Physical quantities, basic tests
*/
//! Physical quantities, basic tests
class CTestPhysicalQuantities : public QObject
{
Q_OBJECT

View File

@@ -9,8 +9,8 @@
//! \file
#ifndef BLACKMISC_SERVER_H
#define BLACKMISC_SERVER_H
#ifndef BLACKMISC_TESTVALUEOBJECT_H
#define BLACKMISC_TESTVALUEOBJECT_H
#include "blackmisc/propertyindex.h"
#include "blackmisc/sequence.h"
@@ -19,9 +19,7 @@
namespace BlackMisc
{
/*!
* Value object encapsulating information of a server
*/
//! Test value object
class CTestValueObject : public BlackMisc::CValueObject<CTestValueObject>
{
public:

View File

@@ -1,7 +1,13 @@
/* 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/. */
/* Copyright (C) 2013
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISCTEST_TESTVARIANTANDMAP_H
#define BLACKMISCTEST_TESTVARIANTANDMAP_H
@@ -12,10 +18,7 @@
namespace BlackMiscTest
{
/*!
* \brief Variant and map related tests
*/
//! Variant and map related tests
class CTestVariantAndMap : public QObject
{
Q_OBJECT