Double posinit test
Testcase for running posinit twice. posinit sets various properties which it then reads, so there's a possibility that it could write a value which causes unexpected behaviour when run later. Unclear if this should be a unit test or a system test, but it's simple enough to be a unit test.
This commit is contained in:
parent
f5b469aee0
commit
24c21bf876
2 changed files with 46 additions and 2 deletions
|
@ -67,7 +67,6 @@ void PosInitTests::checkPosition(SGGeod expectedPos, float delta)
|
||||||
{
|
{
|
||||||
double dist = SGGeodesy::distanceM(globals->get_aircraft_position(),
|
double dist = SGGeodesy::distanceM(globals->get_aircraft_position(),
|
||||||
expectedPos);
|
expectedPos);
|
||||||
std::cerr << "Position distance " << dist << "\n";
|
|
||||||
CPPUNIT_ASSERT_MESSAGE("Unexpected Position", dist < delta);
|
CPPUNIT_ASSERT_MESSAGE("Unexpected Position", dist < delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +183,7 @@ void PosInitTests::testAirportAndRunwayStartup()
|
||||||
|
|
||||||
checkClosestAirport(std::string("EDDF"));
|
checkClosestAirport(std::string("EDDF"));
|
||||||
checkPosition(FGAirport::getByIdent("EDDF")->geod(), 10000.0);
|
checkPosition(FGAirport::getByIdent("EDDF")->geod(), 10000.0);
|
||||||
|
checkHeading(250.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosInitTests::testAirportAndParkingStartup()
|
void PosInitTests::testAirportAndParkingStartup()
|
||||||
|
@ -534,3 +534,42 @@ void PosInitTests::testCarrierStartup()
|
||||||
checkPosition(SGGeod::fromDeg(-122.6, 37.8), 100.0);
|
checkPosition(SGGeod::fromDeg(-122.6, 37.8), 100.0);
|
||||||
checkOnGround();
|
checkOnGround();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PosInitTests::testAirportRepositionAirport()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Options* opts = Options::sharedInstance();
|
||||||
|
opts->setShouldLoadDefaultConfig(false);
|
||||||
|
|
||||||
|
const char* args[] = {"dummypath", "--airport=EDDF", "--runway=25C"};
|
||||||
|
opts->init(3, (char**) args, SGPath());
|
||||||
|
opts->processOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Preset heading " << fgGetDouble("/sim/presets/heading-deg") << "\n";
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(fgGetBool("/sim/presets/airport-requested"));
|
||||||
|
CPPUNIT_ASSERT(fgGetBool("/sim/presets/runway-requested"));
|
||||||
|
checkRunway(std::string("25C"));
|
||||||
|
initPosition();
|
||||||
|
|
||||||
|
checkClosestAirport(std::string("EDDF"));
|
||||||
|
checkPosition(FGAirport::getByIdent("EDDF")->geod(), 10000.0);
|
||||||
|
checkHeading(250.0);
|
||||||
|
|
||||||
|
std::cout << "Preset heading " << fgGetDouble("/sim/presets/heading-deg") << "\n";
|
||||||
|
|
||||||
|
// Now re-position to KSFO runway
|
||||||
|
// Reset the Lat/Lon as these will be used in preference to the airport ID
|
||||||
|
fgSetDouble("/sim/presets/longitude-deg", -9990.00);
|
||||||
|
fgSetDouble("/sim/presets/latitude-deg", -9990.00);
|
||||||
|
fgSetString("/sim/presets/airport-id", "KHAF");
|
||||||
|
fgSetDouble("/sim/presets/heading-deg", 9990.00);
|
||||||
|
fgSetString("/sim/presets/runway", "12");
|
||||||
|
initPosition();
|
||||||
|
|
||||||
|
checkClosestAirport(std::string("KHAF"));
|
||||||
|
checkPosition(FGAirport::getByIdent("KHAF")->geod(), 5000.0);
|
||||||
|
checkHeading(137.0); // Lots of magnetic variation in SF Bay area!
|
||||||
|
checkOnGround();
|
||||||
|
}
|
||||||
|
|
|
@ -55,13 +55,15 @@ class PosInitTests : public CppUnit::TestFixture
|
||||||
CPPUNIT_TEST(testLatLonStartup);
|
CPPUNIT_TEST(testLatLonStartup);
|
||||||
//CPPUNIT_TEST(testLatLonOffsetStartup); This is not yet supported.
|
//CPPUNIT_TEST(testLatLonOffsetStartup); This is not yet supported.
|
||||||
|
|
||||||
|
|
||||||
// Carrier tests
|
// Carrier tests
|
||||||
// We are not able to test the carrier code thoroughly as it depends
|
// We are not able to test the carrier code thoroughly as it depends
|
||||||
// heavily on finalizePosition(), which requires that the carrier model
|
// heavily on finalizePosition(), which requires that the carrier model
|
||||||
// itself be loaded into the scenegraph.
|
// itself be loaded into the scenegraph.
|
||||||
CPPUNIT_TEST(testCarrierStartup);
|
CPPUNIT_TEST(testCarrierStartup);
|
||||||
|
|
||||||
|
// Reposition tests
|
||||||
|
CPPUNIT_TEST(testAirportRepositionAirport);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -97,6 +99,9 @@ public:
|
||||||
//Carrier tests
|
//Carrier tests
|
||||||
void testCarrierStartup();
|
void testCarrierStartup();
|
||||||
|
|
||||||
|
//Reposition tests
|
||||||
|
void testAirportRepositionAirport();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Helper functions for tests. Return void as they use CPPUNIT_ASSERT
|
// Helper functions for tests. Return void as they use CPPUNIT_ASSERT
|
||||||
void checkAlt(float value);
|
void checkAlt(float value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue