diff --git a/test_suite/unit_tests/Navaids/test_flightplan.cxx b/test_suite/unit_tests/Navaids/test_flightplan.cxx index fe173c66c..398d2312e 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.cxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.cxx @@ -122,6 +122,19 @@ public: _plan->insertWayptAtIndex(w, insertIndex++); } } + + if (_plan->approach()) { + WayptVec approachRoute; + bool ok = _plan->approach()->routeFromVectors(approachRoute); + if (!ok) + throw sg_exception("failed to route approach"); + int insertIndex = leg->index(); + for (auto w : approachRoute) { + w->setFlag(WPT_ARRIVAL); + w->setFlag(WPT_GENERATED); + _plan->insertWayptAtIndex(w, insertIndex++); + } + } } @@ -352,6 +365,30 @@ void FlightplanTests::testRoutePathVec() //CPPUNIT_ASSERT(vec.front() } +void FlightplanTests::testRoutePathFinalLegVQPR15() +{ + // test behaviour of RoutePath when the last leg prior to the arrival runway + // is beyond the runway. This occurs in Paro RNAVZ15 approach. + + if (!static_haveProcedures) + return; + + static_factory = std::make_shared(); + FlightPlan::registerDelegateFactory(static_factory); + + FlightPlanRef f = new FlightPlan; + auto ourDelegate = TestFPDelegateFactory::delegateForPlan(f); + + auto vidp = FGAirport::findByIdent("VIDP"); + f->setDeparture(vidp->getRunwayByIdent("09")); + + auto vqpr = FGAirport::findByIdent("VQPR"); + f->setDestination(vqpr->getRunwayByIdent("15")); + f->setApproach(vqpr->findApproachWithIdent("RNVZ15")); + RoutePath rtepath(f); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1100, rtepath.distanceForIndex(14), 100); // calculated from raw lat lon. +} + void FlightplanTests::testRoutPathWpt0Midflight() { // test behaviour of RoutePath when WP0 is not a runway @@ -1064,6 +1101,4 @@ void FlightplanTests::testCloningProcedures() { CPPUNIT_ASSERT_EQUAL(fp2->star()->ident(), string{"EEL1A"}); CPPUNIT_ASSERT_EQUAL(fp2->starTransition()->ident(), string{"BEDUM"}); - - -} +} \ No newline at end of file diff --git a/test_suite/unit_tests/Navaids/test_flightplan.hxx b/test_suite/unit_tests/Navaids/test_flightplan.hxx index abf1ab3b3..f9db5f38a 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.hxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.hxx @@ -40,6 +40,7 @@ class FlightplanTests : public CppUnit::TestFixture CPPUNIT_TEST(testBug1814); CPPUNIT_TEST(testRoutPathWpt0Midflight); CPPUNIT_TEST(testRoutePathVec); + CPPUNIT_TEST(testRoutePathFinalLegVQPR15); CPPUNIT_TEST(testLoadSaveMachRestriction); CPPUNIT_TEST(testOnlyDiscontinuityRoute); CPPUNIT_TEST(testBasicDiscontinuity); @@ -76,6 +77,7 @@ public: void testBug1814(); void testRoutPathWpt0Midflight(); void testRoutePathVec(); + void testRoutePathFinalLegVQPR15(); void testLoadSaveMachRestriction(); void testBasicDiscontinuity(); void testOnlyDiscontinuityRoute();