TestSuite: Migration of the Navaids tests into the CppUnit infrastructure.
This commit is contained in:
parent
236b7c0f83
commit
3c9d3590d4
7 changed files with 86 additions and 31 deletions
|
@ -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(LaRCSimMatrixUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u LaRCSimMatrixTests)
|
||||||
add_test(MktimeUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u MktimeTests)
|
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(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)
|
add_test(PosInitUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u PosInitTests)
|
||||||
|
|
||||||
# GUI test suites.
|
# GUI test suites.
|
||||||
|
|
|
@ -2,6 +2,7 @@ set(TESTSUITE_SOURCES
|
||||||
${TESTSUITE_SOURCES}
|
${TESTSUITE_SOURCES}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
|
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test_flightplan.cxx
|
${CMAKE_CURRENT_SOURCE_DIR}/test_flightplan.cxx
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test_navaids2.cxx
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test_flightplan.hxx"
|
#include "test_flightplan.hxx"
|
||||||
|
#include "test_navaids2.hxx"
|
||||||
|
|
||||||
|
|
||||||
// Set up the unit tests.
|
// Set up the unit tests.
|
||||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FlightplanTests, "Unit tests");
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FlightplanTests, "Unit tests");
|
||||||
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NavaidsTests, "Unit tests");
|
||||||
|
|
34
test_suite/unit_tests/Navaids/test_navaids2.cxx
Normal file
34
test_suite/unit_tests/Navaids/test_navaids2.cxx
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include "test_navaids2.hxx"
|
||||||
|
|
||||||
|
#include "test_suite/helpers/globals.hxx"
|
||||||
|
|
||||||
|
#include <Navaids/NavDataCache.hxx>
|
||||||
|
#include <Navaids/navrecord.hxx>
|
||||||
|
#include <Navaids/navlist.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
48
test_suite/unit_tests/Navaids/test_navaids2.hxx
Normal file
48
test_suite/unit_tests/Navaids/test_navaids2.hxx
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _FG_NAVAIDS_UNIT_TESTS_HXX
|
||||||
|
#define _FG_NAVAIDS_UNIT_TESTS_HXX
|
||||||
|
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
|
@ -116,8 +116,6 @@ macro(flightgear_test name sources)
|
||||||
add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name})
|
add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
flightgear_test(test_navs test_navaids2.cxx)
|
|
||||||
|
|
||||||
add_executable(testAeroElement testAeroElement.cxx ${CMAKE_SOURCE_DIR}/src/FDM/AIWake/AeroElement.cxx)
|
add_executable(testAeroElement testAeroElement.cxx ${CMAKE_SOURCE_DIR}/src/FDM/AIWake/AeroElement.cxx)
|
||||||
target_link_libraries(testAeroElement SimGearCore)
|
target_link_libraries(testAeroElement SimGearCore)
|
||||||
add_test(testAeroElement ${EXECUTABLE_OUTPUT_PATH}/testAeroElement)
|
add_test(testAeroElement ${EXECUTABLE_OUTPUT_PATH}/testAeroElement)
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
#include "test_suite/helpers/globals.hxx"
|
|
||||||
|
|
||||||
#include <simgear/misc/test_macros.hxx>
|
|
||||||
|
|
||||||
#include <Navaids/NavDataCache.hxx>
|
|
||||||
#include <Navaids/navrecord.hxx>
|
|
||||||
#include <Navaids/navlist.hxx>
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
Loading…
Reference in a new issue