swift
testongroundinfo.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
7 #include <QTest>
8 
9 #include "test.h"
10 
12 
13 using namespace swift::misc::aviation;
14 
15 namespace MiscTest
16 {
18  class CMiscOnGroundInfo : public QObject
19  {
20  Q_OBJECT
21  private slots:
22  void createDefault();
23  void createFromGndFactorNotOnGround();
24  void createFromGndFactorOnGround();
25  void getGroundFactorUnknown();
26  void getGroundFactorOnGround();
27  void getGroundFactorNotOnGround();
28  };
29 
30  void CMiscOnGroundInfo::createDefault()
31  {
32  COnGroundInfo info;
33  QVERIFY2(info.getGroundFactor() == -1, "Wrong ground factor");
34  QVERIFY2(info.getGroundDetails() == COnGroundInfo::NotSetGroundDetails, "Wrong ground details");
35  QVERIFY2(info.getOnGround() == COnGroundInfo::OnGroundSituationUnknown, "Wrong on ground situation");
36  }
37 
38  void CMiscOnGroundInfo::createFromGndFactorNotOnGround()
39  {
40  COnGroundInfo info(0.5);
41  QCOMPARE(info.getGroundFactor(), 0.5);
42  QVERIFY2(info.getGroundDetails() == COnGroundInfo::OnGroundByInterpolation, "Wrong ground details");
43  QVERIFY2(info.getOnGround() == COnGroundInfo::NotOnGround, "Wrong on ground situation");
44  }
45 
46  void CMiscOnGroundInfo::createFromGndFactorOnGround()
47  {
48  COnGroundInfo info(0.96);
49  QCOMPARE(info.getGroundFactor(), 0.96);
50  QVERIFY2(info.getGroundDetails() == COnGroundInfo::OnGroundByInterpolation, "Wrong ground details");
51  QVERIFY2(info.getOnGround() == COnGroundInfo::OnGround, "Wrong on ground situation");
52  }
53 
54  void CMiscOnGroundInfo::getGroundFactorUnknown()
55  {
56  COnGroundInfo info(COnGroundInfo::OnGroundSituationUnknown, COnGroundInfo::NotSetGroundDetails);
57  QVERIFY2(info.getGroundFactor() == -1, "Wrong ground factor");
58  QVERIFY2(info.getGroundDetails() == COnGroundInfo::NotSetGroundDetails, "Wrong ground details");
59  QVERIFY2(info.getOnGround() == COnGroundInfo::OnGroundSituationUnknown, "Wrong on ground situation");
60  }
61 
62  void CMiscOnGroundInfo::getGroundFactorOnGround()
63  {
64  COnGroundInfo info(COnGroundInfo::OnGround, COnGroundInfo::InFromNetwork);
65  QVERIFY2(info.getGroundFactor() == 1, "Wrong ground factor");
66  QVERIFY2(info.getGroundDetails() == COnGroundInfo::InFromNetwork, "Wrong ground details");
67  QVERIFY2(info.getOnGround() == COnGroundInfo::OnGround, "Wrong on ground situation");
68  }
69 
70  void CMiscOnGroundInfo::getGroundFactorNotOnGround()
71  {
72  COnGroundInfo info(COnGroundInfo::NotOnGround, COnGroundInfo::InFromNetwork);
73  QVERIFY2(info.getGroundFactor() == 0, "Wrong ground factor");
74  QVERIFY2(info.getGroundDetails() == COnGroundInfo::InFromNetwork, "Wrong ground details");
75  QVERIFY2(info.getOnGround() == COnGroundInfo::NotOnGround, "Wrong on ground situation");
76  }
77 
78 } // namespace MiscTest
79 
81 
82 #include "testongroundinfo.moc"
83 
Aviation classes basic tests.
Information about the ground status.
Definition: ongroundinfo.h:19
@ InFromNetwork
received from network
Definition: ongroundinfo.h:38
@ OnGroundByInterpolation
strongest for remote aircraft
Definition: ongroundinfo.h:34
@ NotSetGroundDetails
not set or unknown if correct (e.g.
Definition: ongroundinfo.h:32
double getGroundFactor() const
Get the ground factor Use this for interpolation only!! For just checking if the info is OnGround or ...
Definition: ongroundinfo.h:66
IsOnGround getOnGround() const
Is on ground?
OnGroundDetails getGroundDetails() const
Get ground details.
#define SWIFTTEST_APPLESS_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...
Definition: test.h:36