mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Ref T429, unit test to test same/changed position
This commit is contained in:
@@ -11,14 +11,18 @@
|
|||||||
//! \file
|
//! \file
|
||||||
//! \ingroup testblackmisc
|
//! \ingroup testblackmisc
|
||||||
|
|
||||||
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
|
||||||
@@ -32,6 +36,9 @@ namespace BlackMiscTest
|
|||||||
private slots:
|
private slots:
|
||||||
//! Basic unit tests for interpolation setup
|
//! Basic unit tests for interpolation setup
|
||||||
void setupTests();
|
void setupTests();
|
||||||
|
|
||||||
|
//! Equal situations
|
||||||
|
void equalSituationTests();
|
||||||
};
|
};
|
||||||
|
|
||||||
void CTestInterpolatorMisc::setupTests()
|
void CTestInterpolatorMisc::setupTests()
|
||||||
@@ -51,6 +58,74 @@ namespace BlackMiscTest
|
|||||||
setup2.setEnabledAircraftParts(!setup2.isAircraftPartsEnabled());
|
setup2.setEnabledAircraftParts(!setup2.isAircraftPartsEnabled());
|
||||||
QVERIFY2(setup1 != setup2, "Expect unequal setups (per callsign)");
|
QVERIFY2(setup1 != setup2, "Expect unequal setups (per callsign)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTestInterpolatorMisc::equalSituationTests()
|
||||||
|
{
|
||||||
|
const CCoordinateGeodetic geoPos0 = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
||||||
|
const CCoordinateGeodetic geoPos1 = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1488, CLengthUnit::ft() });
|
||||||
|
const CCoordinateGeodetic geoPos2 = CCoordinateGeodetic::fromWgs84("48° 21′ 14″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
||||||
|
|
||||||
|
CAngle pitch(3.33, CAngleUnit::deg());
|
||||||
|
CAngle bank(-1.0, CAngleUnit::deg());
|
||||||
|
CHeading heading(270.0, CAngleUnit::deg());
|
||||||
|
|
||||||
|
// initial tests
|
||||||
|
const CAircraftSituation s0(geoPos0, heading, pitch, bank);
|
||||||
|
CAircraftSituation s1(s0);
|
||||||
|
CAircraftSituation s2(s0);
|
||||||
|
CAircraftSituation sg1(s0);
|
||||||
|
CAircraftSituation sg2(s0);
|
||||||
|
|
||||||
|
QVERIFY2(s1.equalPbhAndVector(s2), "Expect same PHB/Vector");
|
||||||
|
QVERIFY2(s1.equalPbhVectorAltitude(s2), "Expect same PHB/Vector/Altitude");
|
||||||
|
QVERIFY2(sg1 == sg2, "Expect the same situation");
|
||||||
|
|
||||||
|
sg1 = geoPos1;
|
||||||
|
sg2 = geoPos2;
|
||||||
|
|
||||||
|
QVERIFY2(!sg1.equalPbhVectorAltitude(s0), "Expect different positions");
|
||||||
|
QVERIFY2(!sg2.equalPbhVectorAltitude(s0), "Expect different positions");
|
||||||
|
|
||||||
|
// test all pitch
|
||||||
|
for (int i = 0; i < 361; i++)
|
||||||
|
{
|
||||||
|
pitch = CAngle(i, CAngleUnit::deg());
|
||||||
|
s1.setPitch(pitch);
|
||||||
|
s2.setPitch(pitch);
|
||||||
|
QVERIFY2(s1.equalPbhVectorAltitude(s2), "Pitch test, expect same PHB/Vector/Altitude");
|
||||||
|
pitch = CAngle(i + 1, CAngleUnit::deg());
|
||||||
|
s2.setPitch(pitch);
|
||||||
|
QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Pitch test, expect same PHB/Vector/Altitude");
|
||||||
|
}
|
||||||
|
|
||||||
|
// test all bank
|
||||||
|
s1 = s0;
|
||||||
|
s2 = s0;
|
||||||
|
for (int i = 0; i < 361; i++)
|
||||||
|
{
|
||||||
|
bank = CAngle(i, CAngleUnit::deg());
|
||||||
|
s1.setBank(bank);
|
||||||
|
s2.setBank(bank);
|
||||||
|
QVERIFY2(s1.equalPbhVectorAltitude(s2), "Bank test, expect same PHB/Vector/Altitude");
|
||||||
|
bank = CAngle(i + 1, CAngleUnit::deg());
|
||||||
|
s2.setBank(bank);
|
||||||
|
QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Bank test, expect same PHB/Vector/Altitude");
|
||||||
|
}
|
||||||
|
|
||||||
|
// test all heading
|
||||||
|
s1 = s0;
|
||||||
|
s2 = s0;
|
||||||
|
for (int i = 0; i < 361; i++)
|
||||||
|
{
|
||||||
|
heading = CHeading(i, CAngleUnit::deg());
|
||||||
|
s1.setHeading(heading);
|
||||||
|
s2.setHeading(heading);
|
||||||
|
QVERIFY2(s1.equalPbhVectorAltitude(s2), "Heading test, expect same PHB/Vector/Altitude");
|
||||||
|
heading = CHeading(i + 1, CAngleUnit::deg());
|
||||||
|
s2.setHeading(heading);
|
||||||
|
QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Heading test, expect same PHB/Vector/Altitude");
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//! main
|
//! main
|
||||||
|
|||||||
Reference in New Issue
Block a user