diff --git a/test_suite/CMakeLists.txt b/test_suite/CMakeLists.txt index bc9fb875f..7bfd0fd37 100644 --- a/test_suite/CMakeLists.txt +++ b/test_suite/CMakeLists.txt @@ -68,6 +68,7 @@ add_test(FlightplanUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u F add_test(LaRCSimMatrixUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u LaRCSimMatrixTests) add_test(MktimeUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u MktimeTests) add_test(NasalSysUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u NasalSysTests) +add_test(NavaidsUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u NavaidsTests) add_test(PosInitUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u PosInitTests) # GUI test suites. diff --git a/test_suite/unit_tests/Navaids/CMakeLists.txt b/test_suite/unit_tests/Navaids/CMakeLists.txt index 9266f8be6..fde0718eb 100644 --- a/test_suite/unit_tests/Navaids/CMakeLists.txt +++ b/test_suite/unit_tests/Navaids/CMakeLists.txt @@ -2,6 +2,7 @@ set(TESTSUITE_SOURCES ${TESTSUITE_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx ${CMAKE_CURRENT_SOURCE_DIR}/test_flightplan.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/test_navaids2.cxx PARENT_SCOPE ) diff --git a/test_suite/unit_tests/Navaids/TestSuite.cxx b/test_suite/unit_tests/Navaids/TestSuite.cxx index 8c720a69b..b024ff6c7 100644 --- a/test_suite/unit_tests/Navaids/TestSuite.cxx +++ b/test_suite/unit_tests/Navaids/TestSuite.cxx @@ -18,7 +18,9 @@ */ #include "test_flightplan.hxx" +#include "test_navaids2.hxx" // Set up the unit tests. CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FlightplanTests, "Unit tests"); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NavaidsTests, "Unit tests"); diff --git a/test_suite/unit_tests/Navaids/test_navaids2.cxx b/test_suite/unit_tests/Navaids/test_navaids2.cxx new file mode 100644 index 000000000..d1fb46377 --- /dev/null +++ b/test_suite/unit_tests/Navaids/test_navaids2.cxx @@ -0,0 +1,34 @@ +#include "test_navaids2.hxx" + +#include "test_suite/helpers/globals.hxx" + +#include +#include +#include + + +// Set up function for each test. +void NavaidsTests::setUp() +{ + fgtest::initTestGlobals("navaids2"); +} + + +// Clean up after each test. +void NavaidsTests::tearDown() +{ + fgtest::shutdownTestGlobals(); +} + + +void NavaidsTests::testBasic() +{ + SGGeod egccPos = SGGeod::fromDeg(-2.27, 53.35); + FGNavRecordRef tla = FGNavList::findByFreq(115.7, egccPos); + + CPPUNIT_ASSERT_EQUAL(strcmp(tla->get_ident(), "TNT"), 0); + CPPUNIT_ASSERT(tla->ident() == "TNT"); + CPPUNIT_ASSERT(tla->name() == "TRENT VOR-DME"); + CPPUNIT_ASSERT_EQUAL(tla->get_freq(), 11570); + CPPUNIT_ASSERT_EQUAL(tla->get_range(), 130); +} diff --git a/test_suite/unit_tests/Navaids/test_navaids2.hxx b/test_suite/unit_tests/Navaids/test_navaids2.hxx new file mode 100644 index 000000000..fc982a8dd --- /dev/null +++ b/test_suite/unit_tests/Navaids/test_navaids2.hxx @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018 Edward d'Auvergne + * + * This file is part of the program FlightGear. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#ifndef _FG_NAVAIDS_UNIT_TESTS_HXX +#define _FG_NAVAIDS_UNIT_TESTS_HXX + + +#include +#include + + +// The flight plan unit tests. +class NavaidsTests : public CppUnit::TestFixture +{ + // Set up the test suite. + CPPUNIT_TEST_SUITE(NavaidsTests); + CPPUNIT_TEST(testBasic); + CPPUNIT_TEST_SUITE_END(); + +public: + // Set up function for each test. + void setUp(); + + // Clean up after each test. + void tearDown(); + + // The tests. + void testBasic(); +}; + +#endif // _FG_NAVAIDS_UNIT_TESTS_HXX diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a8b4ced5..4fa36f6f9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -116,8 +116,6 @@ macro(flightgear_test name sources) add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name}) endmacro() -flightgear_test(test_navs test_navaids2.cxx) - add_executable(testAeroElement testAeroElement.cxx ${CMAKE_SOURCE_DIR}/src/FDM/AIWake/AeroElement.cxx) target_link_libraries(testAeroElement SimGearCore) add_test(testAeroElement ${EXECUTABLE_OUTPUT_PATH}/testAeroElement) diff --git a/tests/test_navaids2.cxx b/tests/test_navaids2.cxx deleted file mode 100644 index fdddde037..000000000 --- a/tests/test_navaids2.cxx +++ /dev/null @@ -1,29 +0,0 @@ -#include "test_suite/helpers/globals.hxx" - -#include - -#include -#include -#include - -void testBasic() -{ - SGGeod egccPos = SGGeod::fromDeg(-2.27, 53.35); - FGNavRecordRef tla = FGNavList::findByFreq(115.7, egccPos); - - SG_CHECK_EQUAL(strcmp(tla->get_ident(), "TNT"), 0); - SG_CHECK_EQUAL(tla->ident(), "TNT"); - SG_CHECK_EQUAL(tla->name(), "TRENT VOR-DME"); - SG_CHECK_EQUAL(tla->get_freq(), 11570); - SG_CHECK_EQUAL(tla->get_range(), 130); - -} - -int main(int argc, char* argv[]) -{ - fgtest::initTestGlobals("navaids2"); - - testBasic(); - - fgtest::shutdownTestGlobals(); -}