refs #893, unit test for property index

This commit is contained in:
Klaus Basan
2017-03-01 04:05:12 +01:00
committed by Mathew Sutcliffe
parent 88106d6d8a
commit f8b2e4f23f
3 changed files with 86 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include "testmath.h"
#include "testphysicalquantities.h"
#include "testprocess.h"
#include "testpropertyindex.h"
#include "testslot.h"
#include "teststringutils.h"
#include "testvaluecache.h"
@@ -51,6 +52,10 @@ namespace BlackMiscTest
CTestAviation avBaseTests;
status |= test.exec(&avBaseTests, "blackmisc_aviation");
}
{
CTestPropertyIndex piTests;
status |= test.exec(&piTests, "blackmisc_propertyindex");
}
{
CTestGeo geoTests;
status |= test.exec(&geoTests, "blackmisc_geo");

View File

@@ -0,0 +1,43 @@
/* Copyright (C) 2017
* 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.
*/
//! \cond PRIVATE_TESTS
//! \file
//! \ingroup testblackmisc
#include "testpropertyindex.h"
#include "blackmisc/simulation/simulatedaircraft.h"
#include <QTest>
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackMiscTest
{
CTestPropertyIndex::CTestPropertyIndex(QObject *parent): QObject(parent)
{
// void
}
void CTestPropertyIndex::propertyIndexCSimulatedAircraft()
{
const CFrequency f(123.50, CFrequencyUnit::MHz());
const CPropertyIndex i({ CSimulatedAircraft::IndexCom1System, CComSystem::IndexActiveFrequency });
CSimulatedAircraft aircraft;
aircraft.setCallsign("DEIHL");
aircraft.setCom1ActiveFrequency(f);
CVariant vf = aircraft.propertyByIndex(i);
const CFrequency pf = vf.value<CFrequency>();
QVERIFY2(pf == f, "Frequencies should have same value");
}
} // namespace
//! \endcond

View File

@@ -0,0 +1,38 @@
/* Copyright (C) 2017
* 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_TESTPROPERTYINDEX_H
#define BLACKMISCTEST_TESTPROPERTYINDEX_H
//! \cond PRIVATE_TESTS
//! \file
//! \ingroup testblackmisc
#include <QObject>
namespace BlackMiscTest
{
//! Testing property index access
class CTestPropertyIndex : public QObject
{
Q_OBJECT
public:
//! Standard test case constructor
explicit CTestPropertyIndex(QObject *parent = nullptr);
private slots:
//! Simulated aircraft index checks
void propertyIndexCSimulatedAircraft();
};
} // namespace
//! \endcond
#endif // guard