swift
testinterpolatormisc.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
7 
8 #include <QDebug>
9 #include <QTest>
10 #include <QtDebug>
11 
12 #include "test.h"
13 
16 
17 using namespace swift::misc::aviation;
18 using namespace swift::misc::geo;
19 using namespace swift::misc::physical_quantities;
20 using namespace swift::misc::simulation;
21 
22 namespace MiscTest
23 {
25  class CTestInterpolatorMisc : public QObject
26  {
27  Q_OBJECT
28 
29  private slots:
31  void setupTests();
32 
34  void equalSituationTests();
35  };
36 
37  void CTestInterpolatorMisc::setupTests()
38  {
41 
42  QVERIFY2(gs1 == gs2, "Expect equal setups");
43  const CLength l(100, CLengthUnit::m());
44  gs2.setMaxRenderedDistance(l);
45  QVERIFY2(gs1 != gs2, "Expect unequal setups");
46 
47  const CCallsign cs("DAMBZ");
48  const CInterpolationAndRenderingSetupPerCallsign setup1(cs, gs1);
50  QVERIFY2(setup1 == setup2, "Expect equal setups (per callsign)");
51  setup2.setEnabledAircraftParts(!setup2.isAircraftPartsEnabled());
52  QVERIFY2(setup1 != setup2, "Expect unequal setups (per callsign)");
53  }
54 
55  void CTestInterpolatorMisc::equalSituationTests()
56  {
57  const CCoordinateGeodetic geoPos0 =
58  CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
59  const CCoordinateGeodetic geoPos1 =
60  CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1488, CLengthUnit::ft() });
61  const CCoordinateGeodetic geoPos2 =
62  CCoordinateGeodetic::fromWgs84("48° 21′ 14″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
63 
64  CAngle pitch(3.33, CAngleUnit::deg());
65  CAngle bank(-1.0, CAngleUnit::deg());
66  CHeading heading(270.0, CAngleUnit::deg());
67 
68  // initial tests
69  const CAircraftSituation s0(geoPos0, heading, pitch, bank);
70  CAircraftSituation s1(s0);
71  CAircraftSituation s2(s0);
72  CAircraftSituation sg1(s0);
73  CAircraftSituation sg2(s0);
74 
75  QVERIFY2(s1.equalPbhAndVector(s2), "Expect same PHB/Vector");
76  QVERIFY2(s1.equalPbhVectorAltitude(s2), "Expect same PHB/Vector/Altitude");
77  QVERIFY2(sg1 == sg2, "Expect the same situation");
78 
79  sg1 = geoPos1;
80  sg2 = geoPos2;
81 
82  QVERIFY2(!sg1.equalPbhVectorAltitude(s0), "Expect different positions");
83  QVERIFY2(!sg2.equalPbhVectorAltitude(s0), "Expect different positions");
84 
85  // test all pitch
86  for (int i = 0; i < 361; i++)
87  {
88  pitch = CAngle(i, CAngleUnit::deg());
89  s1.setPitch(pitch);
90  s2.setPitch(pitch);
91  QVERIFY2(s1.equalPbhVectorAltitude(s2), "Pitch test, expect same PHB/Vector/Altitude");
92  pitch = CAngle(i + 1, CAngleUnit::deg());
93  s2.setPitch(pitch);
94  QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Pitch test, expect same PHB/Vector/Altitude");
95  }
96 
97  // test all bank
98  s1 = s0;
99  s2 = s0;
100  for (int i = 0; i < 361; i++)
101  {
102  bank = CAngle(i, CAngleUnit::deg());
103  s1.setBank(bank);
104  s2.setBank(bank);
105  QVERIFY2(s1.equalPbhVectorAltitude(s2), "Bank test, expect same PHB/Vector/Altitude");
106  bank = CAngle(i + 1, CAngleUnit::deg());
107  s2.setBank(bank);
108  QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Bank test, expect same PHB/Vector/Altitude");
109  }
110 
111  // test all heading
112  s1 = s0;
113  s2 = s0;
114  for (int i = 0; i < 361; i++)
115  {
116  heading = CHeading(i, CAngleUnit::deg());
117  s1.setHeading(heading);
118  s2.setHeading(heading);
119  QVERIFY2(s1.equalPbhVectorAltitude(s2), "Heading test, expect same PHB/Vector/Altitude");
120  heading = CHeading(i + 1, CAngleUnit::deg());
121  s2.setHeading(heading);
122  QVERIFY2(!s1.equalPbhVectorAltitude(s2), "Heading test, expect same PHB/Vector/Altitude");
123  }
124  }
125 } // namespace MiscTest
126 
129 
130 #include "testinterpolatormisc.moc"
131 
Interpolator related basic tests.
Value object encapsulating information of an aircraft's situation.
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Heading as used in aviation, can be true or magnetic heading.
Definition: heading.h:41
Physical unit angle (radians, degrees)
Definition: angle.h:23
Physical unit length (length)
Definition: length.h:18
Value object for interpolator and rendering per callsign.
SWIFTTEST_MAIN(MiscTest::CTestInterpolatorMisc)
main