/* SPDX-Copyright: James Turner SPDX-License-Identifier: GPL-2.0-or-later */ #include "test_condition.hxx" #include #include #include #include #include "test_suite/FGTestApi/testGlobals.hxx" // Set up function for each test. void SimgearConditionTests::setUp() { // Create a property tree. tree = new SGPropertyNode; } // Clean up SimgearConditionTests each test. void SimgearConditionTests::tearDown() { } // Test property aliasing, to catch possible memory leaks. void SimgearConditionTests::testEmptyCondition() { auto config = FGTestApi::propsFromString(R"( /foo/bar )"); sglog().setDeveloperMode(true); CPPUNIT_ASSERT_THROW(sgReadCondition(tree, config->getChild("enabled")), sg_exception); // repeat in non-developer mode; test the legacy behaviour sglog().setDeveloperMode(false); auto n2 = sgReadCondition(tree, config->getChild("enabled")); CPPUNIT_ASSERT(n2); CPPUNIT_ASSERT(n2->test()); }