1
0
Fork 0

Add test case for issue with last waypoint being a runway

This commit is contained in:
legoboyvdlp R 2020-07-24 20:59:57 +01:00 committed by James Turner
parent 668b499ff4
commit 02c7b37122
2 changed files with 52 additions and 0 deletions

View file

@ -1529,3 +1529,53 @@ void GPSTests::testDMEIntercept()
CPPUNIT_ASSERT(ok);
}
void GPSTests::testFinalLegCourse()
{
// FGTestApi::setUp::logPositionToKML("gps_dme_intercept");
auto rm = globals->get_subsystem<FGRouteMgr>();
auto fp = new FlightPlan;
rm->setFlightPlan(fp);
// we can't use the standard function as it puts a waypoint on
// the extended centerline
FGAirportRef depApt = FGAirport::getByIdent("EGAA");
fp->setDeparture(depApt->getRunwayByIdent("07"));
FGAirportRef destApt = FGAirport::getByIdent("EGPF");
fp->setDestination(destApt->getRunwayByIdent("23"));
// since we don't have the Nasal route-manager delegate, insert the
// runway waypoints manually
auto depRwy = new RunwayWaypt(fp->departureRunway(), fp);
depRwy->setFlag(WPT_DEPARTURE);
fp->insertWayptAtIndex(depRwy, -1);
fp->insertWayptAtIndex(fp->waypointFromString("LISBO"), -1);
auto destRwy = fp->destinationRunway();
fp->insertWayptAtIndex(new RunwayWaypt(destRwy, fp), -1);
// takes the place of the Nasal delegates
auto testDelegate = new TestFPDelegate;
testDelegate->thePlan = fp;
CPPUNIT_ASSERT(rm->activate());
fp->addDelegate(testDelegate);
auto gps = setupStandardGPS();
fp->setCurrentIndex(2);
// position halfway between EGAA and EGPF
SGGeod initPos = fp->pointAlongRoute(1, -30.5);
FGTestApi::setPositionAndStabilise(initPos);
auto gpsNode = globals->get_props()->getNode("instrumentation/gps");
gpsNode->setBoolValue("config/delegate-sequencing", true);
gpsNode->setStringValue("command", "leg");
FGTestApi::writeFlightPlanToKML(fp);
// check that the final leg course doesn't fall back to 233 deg
CPPUNIT_ASSERT_DOUBLES_EQUAL(37, gpsNode->getDoubleValue("desired-course-deg"), 2.0);
}

View file

@ -54,6 +54,7 @@ class GPSTests : public CppUnit::TestFixture
CPPUNIT_TEST(testBuiltinRevertToOBSAtEnd);
CPPUNIT_TEST(testRadialIntercept);
CPPUNIT_TEST(testDMEIntercept);
CPPUNIT_TEST(testFinalLegCourse);
CPPUNIT_TEST_SUITE_END();
@ -88,6 +89,7 @@ public:
void testBuiltinRevertToOBSAtEnd();
void testRadialIntercept();
void testDMEIntercept();
void testFinalLegCourse();
};
#endif // _FG_GPS_UNIT_TESTS_HXX