26 #include "misc/aviation/waketurbulencecategory.h"
39 using namespace swift::misc::aviation;
40 using namespace swift::misc::physical_quantities;
41 using namespace swift::misc::network;
42 using namespace swift::misc::geo;
59 void sameAviationFrequency();
62 void comFrequencyRounding();
68 void callsignWithContainers();
80 void testWakeTurbulenceCategories();
83 void CTestAviation::headingBasics()
88 CAngle a1(200, CAngleUnit::deg());
91 QVERIFY2(h1 != h2,
"Magnetic and true heading are not the same");
92 QVERIFY2(h1 < h3,
"180deg are less than 181deg");
93 QVERIFY2(h3 > h1,
"181deg are more than 181deg");
94 QVERIFY2(a1 > h3,
"200deg are more than 181deg");
95 QVERIFY2(h4 == h1,
"Values shall be equal");
99 QVERIFY2(h1.isZeroEpsilonConsidered(),
"Expect zero value");
100 QCOMPARE(h1.value(), 0.0);
104 QCOMPARE(h2.value(), 360.0);
107 void CTestAviation::comAndNav()
111 QVERIFY2(c1 != c2,
"COM system shall not be equal");
113 QVERIFY2(c1 == c2,
"COM system shall be equal");
115 "Expect valid nav frequency");
117 "Expect invalid nav frequency");
120 void CTestAviation::sameAviationFrequency()
123 CFrequency freq1(129620000, CFrequencyUnit::Hz());
124 CFrequency freq2(129620000, CFrequencyUnit::Hz());
129 CFrequency freq1(122.8, CFrequencyUnit::MHz());
130 CFrequency freq2(122.8, CFrequencyUnit::MHz());
136 CFrequency freq1(123450001, CFrequencyUnit::Hz());
137 CFrequency freq2(123450, CFrequencyUnit::kHz());
144 CFrequency freq1(118.325, CFrequencyUnit::MHz());
145 CFrequency freq2(118.320, CFrequencyUnit::MHz());
146 CFrequency freq3(132.770, CFrequencyUnit::MHz());
147 CFrequency freq4(132.775, CFrequencyUnit::MHz());
148 CFrequency freq5(132.765, CFrequencyUnit::MHz());
149 CFrequency freq6(132.780, CFrequencyUnit::MHz());
164 CFrequency freq1(129620000, CFrequencyUnit::Hz());
165 CFrequency freq2(132025000, CFrequencyUnit::Hz());
171 CFrequency freq1(118.305, CFrequencyUnit::MHz());
172 CFrequency freq2(118305, CFrequencyUnit::kHz());
177 CFrequency freq1(118.310, CFrequencyUnit::MHz());
178 CFrequency freq2(118305, CFrequencyUnit::kHz());
183 CFrequency freq1(135.660, CFrequencyUnit::MHz());
184 CFrequency freq2(135665, CFrequencyUnit::kHz());
189 void CTestAviation::comFrequencyRounding()
197 QVERIFY2(f1 == f1,
"Ups, how can this fail");
198 QVERIFY2(f1 != f2,
"Ups, how can this fail");
199 QVERIFY2(f1 != f3,
"Ups, how can this fail");
200 QVERIFY2(f4 != f5,
"Ups, how can this fail");
204 QVERIFY2(up == f1,
"Expect rounding up");
208 QVERIFY2(down == f1,
"Expect rounding up");
212 QVERIFY2(same != f1,
"Expect no rounding");
213 QVERIFY2(same == f3,
"Expect no rounding");
217 QVERIFY2(up2 == f4,
"Expect rounding up");
220 void CTestAviation::transponder()
224 QVERIFY2(t1 == t2,
"Transponders shall be equal");
226 QVERIFY2(t1 != t2,
"Transponders shall not be equal");
228 QVERIFY2(!tv.
validValues(),
"No valid transponder");
230 QVERIFY2(!tv.
validValues(),
"No valid transponder");
232 QVERIFY2(!tv.
validValues(),
"No valid transponder");
234 QVERIFY2(tv.
validValues(),
"No valid transponder");
236 QVERIFY2(!tv.
validValues(),
"No valid transponder");
239 void CTestAviation::callsignWithContainers()
243 const CCallsign cs3(
"EDDm_app",
"München Radar");
244 QVERIFY2(cs1 == cs2,
"Callsigns shall be equal");
245 QVERIFY2(cs1 != cs3,
"Callsigns shall not be equal");
251 QVERIFY(copilot1.isMaybeCopilotCallsign(pilot));
252 QVERIFY(!pilot.isMaybeCopilotCallsign(pilot));
253 QVERIFY(!copilot2.isMaybeCopilotCallsign(pilot));
254 QVERIFY(!copilot3.isMaybeCopilotCallsign(pilot));
256 QString flightnumber;
259 QString prefix = pilot.getAirlinePrefix(flightnumber, identifier);
260 QVERIFY(prefix ==
"DLH");
261 QVERIFY(flightnumber ==
"123");
262 QVERIFY(flightnumber == identifier);
263 prefix = copilot1.getAirlinePrefix(flightnumber, identifier);
264 QVERIFY(prefix ==
"DLH");
265 QVERIFY(flightnumber ==
"123");
266 QVERIFY(flightnumber != identifier);
267 prefix = copilot3.getAirlinePrefix(flightnumber);
268 QVERIFY(prefix ==
"DLH");
269 QVERIFY(flightnumber ==
"12");
272 prefix = pilotX1.getAirlinePrefix(flightnumber);
273 QVERIFY(prefix.isEmpty());
274 QVERIFY(flightnumber.isEmpty());
277 prefix = pilotX2.getAirlinePrefix(flightnumber, identifier);
278 QVERIFY(prefix ==
"DLH");
279 QVERIFY(flightnumber ==
"1");
280 QVERIFY(identifier ==
"1WP");
284 QVERIFY2(set.
size() == 1,
"List shall be 1");
285 QVERIFY2(set.
contains(cs1),
"Callsign is in list");
286 QVERIFY2(set.
contains(cs2),
"Callsign is in list");
288 QVERIFY2(cs1 == cs1,
"Callsign is the same, shall be equal");
289 QVERIFY2(set.
size() == 0,
"List shall be 0 after removal");
292 QVERIFY2(set.
size() == 1,
"Duplicates shall not be added");
294 QVERIFY2(set.
size() == 2,
"2 different callsigns");
296 QVERIFY2(set.
size() == 1,
"Only one should be left in list");
298 QVERIFY2(set.
size() == 0,
"Last should be gone");
301 void CTestAviation::copyAndEqual()
303 const CFrequency f1(123.45, CFrequencyUnit::MHz());
305 QVERIFY2(f1 == f2,
"frequencies shall be equal");
309 QVERIFY2(c1 == c2,
"callsigns shall be equal");
313 QVERIFY2(im1 == im2,
"information shall be equal");
315 const CUser user1(
"112233dd",
"Joe",
"",
"secret");
316 const CUser user2(user1);
317 QVERIFY2(user1 == user2,
"information shall be equal");
320 CServer(
"Testserver",
"Client project testserver",
"localhost", 6809,
CUser(
"111111",
"My Name",
"",
"123"),
322 const CServer server2(server1);
323 QVERIFY2(server1 == server2,
"server shall be equal");
326 CLongitude::fromWgs84(
"E 008° 27' 05"),
329 QVERIFY2(situation1 == situation2,
"situations shall be equal");
333 QVERIFY2(aircraftIcao1 == aircraftIcao2,
"aircraft ICAOs shall be equal");
337 QVERIFY2(airlineIcao1 == airlineIcao2,
"airline ICAOs shall be equal");
339 const CCallsign call1(
"EDDS_N_APP", CCallsign::Atc);
340 const CCallsign call2(
"edds_n_app", CCallsign::Atc);
341 QVERIFY2(call1 == call2,
"Callsigns shall be equal");
343 const CAtcStation atc1(c1, user1, f1, situation1.getPosition(),
CLength(),
false, QDateTime(),
345 const CAtcStation atc2(c1, user1, f1, situation1.getPosition(),
CLength(),
false, QDateTime(),
347 const CAtcStation atc3(c1, user1, f1, situation1.getPosition(),
CLength(),
false, QDateTime(),
349 QVERIFY2(atc1 == atc2,
"ATC stations shall be equal");
350 QVERIFY2(atc1 != atc3,
"ATC stations shall not be equal");
353 void CTestAviation::altitude()
356 CPressure seaLevelPressure1(1025, CPressureUnit::mbar());
358 QCOMPARE(pressureAltitude1.
value(CLengthUnit::ft()), 95.5);
361 CPressure seaLevelPressure2(29.56, CPressureUnit::inHg());
363 QCOMPARE(qRound(pressureAltitude2.
value(CLengthUnit::m())), 612);
365 CLength offset(10, CLengthUnit::m());
367 QCOMPARE(qRound(altitude2.value(CLengthUnit::m())), 510);
370 void CTestAviation::testGuessing()
376 CSpeed s172, sB737, sB747;
377 s172 = sB737 = sB747 = CSpeed::null();
379 cg172 = cgB737 = cgB747 = CLength::null();
380 icao172.guessModelParameters(cg172, s172);
381 icaoB737.guessModelParameters(cgB737, sB737);
382 icaoB747.guessModelParameters(cgB747, sB747);
384 QVERIFY(cg172 < cgB737);
385 QVERIFY(cgB737 < cgB747);
387 QVERIFY(s172 < sB747);
388 QVERIFY(sB737 < sB747);
391 void CTestAviation::testWakeTurbulenceCategories()
417 QCOMPARE(catLight1.toQString(),
"L");
422 QCOMPARE(catMedium1.toQString(),
"M");
427 QCOMPARE(catHeavy1.toQString(),
"H");
432 QCOMPARE(catSuper1.toQString(),
"J");
435 QVERIFY(catUnknown1.isUnknown());
437 QVERIFY(catUnknown2.isUnknown());
439 QVERIFY(catUnknown3.isUnknown());
441 QVERIFY(catUnknown4.isUnknown());
442 QCOMPARE(catUnknown1.toQString(),
"-");
450 #include "testaviation.moc"
Aviation classes basic tests.
size_type size() const
Returns number of elements in the collection.
void remove(const T &object)
Efficient remove using the find and erase of the implementation container. Typically O(log n).
int removeIf(Predicate p)
Remove elements for which a given predicate returns true.
iterator push_back(const T &value)
Synonym for insert.
bool contains(const T &object) const
Return true if there is an element equal to given object. Uses the most efficient implementation avai...
Value object for ICAO classification.
Value object encapsulating information of an aircraft's situation.
Value object for ICAO classification.
Altitude as used in aviation, can be AGL or MSL altitude.
CAltitude toPressureAltitude(const physical_quantities::CPressure &seaLevelPressure) const
Returns the altitude converted to pressure altitude. Requires the current barometric pressure at MSL.
Value object encapsulating information about an ATC station.
Value object encapsulating information of a callsign.
const QString & getTelephonyDesignator() const
Get callsign telephony designator (how callsign is pronounced)
Value object for a set of callsigns.
static void roundToChannelSpacing(physical_quantities::CFrequency &frequency, ChannelSpacing channelSpacing)
Round to channel spacing, set MHz as unit.
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz=-1)
COM1 unit.
static bool isSameFrequency(const physical_quantities::CFrequency &freq1, const physical_quantities::CFrequency &freq2)
Compare frequencies under consideration that on VATSIM frequencies .x20/.x25 and ....
@ ChannelSpacing25KHz
25kHz
@ ChannelSpacing8_33KHz
8.33kHz
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz=-1)
COM2 unit.
Heading as used in aviation, can be true or magnetic heading.
static bool isValidCivilNavigationFrequency(const swift::misc::physical_quantities::CFrequency &f)
Valid civil aviation frequency?
static CTransponder getStandardTransponder(qint32 transponderCode, TransponderMode mode)
Transponder unit.
bool setTransponderMode(TransponderMode mode)
Set transponder mode.
bool validValues() const
Are set values valid?
@ StateStandby
not a real mode, more a state
ICAO wake turbulence category.
@ UNKNOWN
required when converting from FAA equipment codes and for some database entries where the correct WTC...
Ecosystem of server belonging together.
Value object for a FSD setup.
Value object encapsulating information of a server.
Value object encapsulating information of a user.
Physical unit angle (radians, degrees)
Physical unit length (length)
double value(MU unit) const
Value in given unit.
SWIFTTEST_APPLESS_MAIN(MiscTest::CTestAviation)
main