Debian Codegraph @

test_suite/system_tests/subsystems/test_instanced_creation.cxx

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 Edward d'Auvergne
3 *
4 * This file is part of the program FlightGear.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "test_suite/FGTestApi/testGlobals.hxx"
21
22 #include "test_instanced_creation.hxx"
23
24
25 // Set up function for each test.
26 void InstancedSubsystemTests::setUp()
27 {
28 // First set up the globals object.
29 FGTestApi::setUp::initTestGlobals("InstancedSubsystemCreationTests");
30
31 // The subsystem manager.
32 _mgr.reset(new SGSubsystemMgr());
33 }
34
35
36 // Clean up after each test.
37 void InstancedSubsystemTests::tearDown()
38 {
39 // Remove the manager.
40 _mgr.reset();
41
42 // Clean up globals.
43 FGTestApi::tearDown::shutdownTestGlobals();
44 }
45
46
47 // Helper functions.
48 void InstancedSubsystemTests::create(const char* name)
49 {
50 // Create two subsystem instances and add them to the manager.
51 _mgr->addInstance(name, "inst1");
52 _mgr->addInstance(name, "inst2");
53 auto sub1 = _mgr->get_subsystem(name, "inst1");
54 auto sub2 = _mgr->get_subsystem(name, "inst2");
55
56 // Check the first subsystem.
57 CPPUNIT_ASSERT(sub1);
58 CPPUNIT_ASSERT_EQUAL(sub1->subsystemId(), std::string(name) + ".inst1");
59 CPPUNIT_ASSERT_EQUAL(sub1->subsystemClassId(), std::string(name));
60 CPPUNIT_ASSERT_EQUAL(sub1->subsystemInstanceId(), std::string("inst1"));
61
62 // Check the second subsystem.
63 CPPUNIT_ASSERT(sub2);
64 CPPUNIT_ASSERT_EQUAL(sub2->subsystemId(), std::string(name) + ".inst2");
65 CPPUNIT_ASSERT_EQUAL(sub2->subsystemClassId(), std::string(name));
66 CPPUNIT_ASSERT_EQUAL(sub2->subsystemInstanceId(), std::string("inst2"));
67 }
68
69
70 // The instanced subsystems.
71 void InstancedSubsystemTests::testADF() { create("adf"); }
72 void InstancedSubsystemTests::testAirspeedIndicator() { create("airspeed-indicator"); }
73 void InstancedSubsystemTests::testAltimeter() { create("altimeter"); }
74 void InstancedSubsystemTests::testAttitudeIndicator() { create("attitude-indicator"); }
75 void InstancedSubsystemTests::testClock() { create("clock"); }
76 void InstancedSubsystemTests::testCommRadio() { create("comm-radio"); }
77 void InstancedSubsystemTests::testDME() { create("dme"); }
78 void InstancedSubsystemTests::testFGKR_87() { create("KR-87"); }
79 void InstancedSubsystemTests::testFGMarkerBeacon() { create("marker-beacon"); }
80 void InstancedSubsystemTests::testFGNavRadio() { create("old-navradio"); }
81 void InstancedSubsystemTests::testGPS() { create("gps"); }
82 void InstancedSubsystemTests::testGSDI() { create("gsdi"); }
83 void InstancedSubsystemTests::testHeadingIndicator() { create("heading-indicator"); }
84 void InstancedSubsystemTests::testHeadingIndicatorDG() { create("heading-indicator-dg"); }
85 void InstancedSubsystemTests::testHeadingIndicatorFG() { create("heading-indicator-fg"); }
86 void InstancedSubsystemTests::testHUD() { create("hud"); }
87 void InstancedSubsystemTests::testInstVerticalSpeedIndicator() { create("inst-vertical-speed-indicator"); }
88 void InstancedSubsystemTests::testKLN89() { create("kln89"); }
89 void InstancedSubsystemTests::testMagCompass() { create("magnetic-compass"); }
90 void InstancedSubsystemTests::testMasterReferenceGyro() { create("master-reference-gyro"); }
91 void InstancedSubsystemTests::testMK_VIII() { create("mk-viii"); }
92 void InstancedSubsystemTests::testNavRadio() { create("nav-radio"); }
93 void InstancedSubsystemTests::testRadarAltimeter() { create("radar-altimeter"); }
94 void InstancedSubsystemTests::testSlipSkidBall() { create("slip-skid-ball"); }
95 void InstancedSubsystemTests::testTACAN() { create("tacan"); }
96 void InstancedSubsystemTests::testTCAS() { create("tcas"); }
97 void InstancedSubsystemTests::testTransponder() { create("transponder"); }
98 void InstancedSubsystemTests::testTurnIndicator() { create("turn-indicator"); }
99 void InstancedSubsystemTests::testVerticalSpeedIndicator() { create("vertical-speed-indicator"); }