From eb8b6e6f1f98688c6cf88586e17e088bda23dde3 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 28 May 2015 19:51:34 +0200 Subject: [PATCH] refs #432, unit test for originator, in same step cleaned unit test code a bit (headers, ...) --- tests/blackmisc/blackmisctest.h | 14 ++++---- tests/blackmisc/testaviation.h | 43 +++++++++--------------- tests/blackmisc/testblackmiscmain.cpp | 3 ++ tests/blackmisc/testblackmiscmain.h | 27 +++++++-------- tests/blackmisc/testgeo.h | 43 +++++++++++------------- tests/blackmisc/testhardware.h | 31 +++++++++-------- tests/blackmisc/testoriginator.cpp | 41 ++++++++++++++++++++++ tests/blackmisc/testoriginator.h | 43 ++++++++++++++++++++++++ tests/blackmisc/testphysicalquantities.h | 19 ++++++----- tests/blackmisc/testvalueobject.h | 8 ++--- tests/blackmisc/testvariantandmap.h | 19 ++++++----- 11 files changed, 183 insertions(+), 108 deletions(-) create mode 100644 tests/blackmisc/testoriginator.cpp create mode 100644 tests/blackmisc/testoriginator.h diff --git a/tests/blackmisc/blackmisctest.h b/tests/blackmisc/blackmisctest.h index 03ce5fd3b..f978f71c2 100644 --- a/tests/blackmisc/blackmisctest.h +++ b/tests/blackmisc/blackmisctest.h @@ -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 diff --git a/tests/blackmisc/testaviation.h b/tests/blackmisc/testaviation.h index 75360f12c..6c206e103 100644 --- a/tests/blackmisc/testaviation.h +++ b/tests/blackmisc/testaviation.h @@ -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(); }; diff --git a/tests/blackmisc/testblackmiscmain.cpp b/tests/blackmisc/testblackmiscmain.cpp index 07f8dead0..b7466e81e 100644 --- a/tests/blackmisc/testblackmiscmain.cpp +++ b/tests/blackmisc/testblackmiscmain.cpp @@ -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); diff --git a/tests/blackmisc/testblackmiscmain.h b/tests/blackmisc/testblackmiscmain.h index dad20bf40..9013e0ae1 100644 --- a/tests/blackmisc/testblackmiscmain.h +++ b/tests/blackmisc/testblackmiscmain.h @@ -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[]); }; } diff --git a/tests/blackmisc/testgeo.h b/tests/blackmisc/testgeo.h index bda905e5e..247bb91c4 100644 --- a/tests/blackmisc/testgeo.h +++ b/tests/blackmisc/testgeo.h @@ -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 diff --git a/tests/blackmisc/testhardware.h b/tests/blackmisc/testhardware.h index 81d086097..f38482084 100644 --- a/tests/blackmisc/testhardware.h +++ b/tests/blackmisc/testhardware.h @@ -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 - 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 diff --git a/tests/blackmisc/testoriginator.cpp b/tests/blackmisc/testoriginator.cpp new file mode 100644 index 000000000..1b458a5e1 --- /dev/null +++ b/tests/blackmisc/testoriginator.cpp @@ -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 diff --git a/tests/blackmisc/testoriginator.h b/tests/blackmisc/testoriginator.h new file mode 100644 index 000000000..07c38b2a5 --- /dev/null +++ b/tests/blackmisc/testoriginator.h @@ -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 + +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 diff --git a/tests/blackmisc/testphysicalquantities.h b/tests/blackmisc/testphysicalquantities.h index b8c527a90..a4283496f 100644 --- a/tests/blackmisc/testphysicalquantities.h +++ b/tests/blackmisc/testphysicalquantities.h @@ -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 diff --git a/tests/blackmisc/testvalueobject.h b/tests/blackmisc/testvalueobject.h index ea9361df9..c373da78b 100644 --- a/tests/blackmisc/testvalueobject.h +++ b/tests/blackmisc/testvalueobject.h @@ -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 { public: diff --git a/tests/blackmisc/testvariantandmap.h b/tests/blackmisc/testvariantandmap.h index 574673cf6..46cea8a26 100644 --- a/tests/blackmisc/testvariantandmap.h +++ b/tests/blackmisc/testvariantandmap.h @@ -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