diff --git a/test_suite/unit_tests/Navaids/test_fpNasal.cxx b/test_suite/unit_tests/Navaids/test_fpNasal.cxx index 1b87c0baf..8794c5dc6 100644 --- a/test_suite/unit_tests/Navaids/test_fpNasal.cxx +++ b/test_suite/unit_tests/Navaids/test_fpNasal.cxx @@ -252,3 +252,43 @@ void FPNasalTests::testApproachTransitionAPI() CPPUNIT_ASSERT_EQUAL(string{"LUL1C"}, fp->approachTransition()->ident()); CPPUNIT_ASSERT_EQUAL(string{"ILS08L"}, fp->approach()->ident()); } + +void FPNasalTests::testApproachTransitionAPIWithCloning() +{ + if (!static_haveProcedures) { + return; + } + + auto rm = globals->get_subsystem(); + + bool ok = FGTestApi::executeNasal(R"( + var fp = flightplan(); + fp.departure = airportinfo("EGLL"); + fp.destination = airportinfo("EHAM"); + fp.star = fp.destination.getStar("REDF1A"); + fp.destination_runway = fp.destination.runway('06'); + + var approach = fp.destination.getApproach("ILS06"); + unitTest.assert(approach != nil, "No approach loaded"); + + var trans = approach.transition('SUG2A'); + unitTest.assert(trans != nil, "approach transition not found"); + + fp.approach = trans; + + unitTest.assert_equal(fp.approach.id, "ILS06", "Incorrect approach returned"); + unitTest.assert_equal(fp.approach_trans.id, "SUG2A", "Incorrect transition returned"); + )"); + + CPPUNIT_ASSERT(ok); + + auto fp = rm->flightPlan(); + + CPPUNIT_ASSERT(fp->approach()); + CPPUNIT_ASSERT_EQUAL(string{"SUG2A"}, fp->approachTransition()->ident()); + CPPUNIT_ASSERT_EQUAL(string{"ILS06"}, fp->approach()->ident()); + + auto fp2 = fp->clone("testplan2"); + CPPUNIT_ASSERT_EQUAL(string{"ILS06"}, fp2->approach()->ident()); + CPPUNIT_ASSERT_EQUAL(string{"SUG2A"}, fp2->approachTransition()->ident()); +} \ No newline at end of file diff --git a/test_suite/unit_tests/Navaids/test_fpNasal.hxx b/test_suite/unit_tests/Navaids/test_fpNasal.hxx index 483e9f664..35e7610bb 100644 --- a/test_suite/unit_tests/Navaids/test_fpNasal.hxx +++ b/test_suite/unit_tests/Navaids/test_fpNasal.hxx @@ -34,6 +34,7 @@ class FPNasalTests : public CppUnit::TestFixture CPPUNIT_TEST(testSIDTransitionAPI); CPPUNIT_TEST(testSTARTransitionAPI); CPPUNIT_TEST(testApproachTransitionAPI); + CPPUNIT_TEST(testApproachTransitionAPIWithCloning); CPPUNIT_TEST_SUITE_END(); @@ -50,4 +51,5 @@ public: void testSIDTransitionAPI(); void testSTARTransitionAPI(); void testApproachTransitionAPI(); + void testApproachTransitionAPIWithCloning(); };