Debian Codegraph @

test_suite/simgear_tests/props/test_condition.cxx

raw symbols SCIP
1 /*
2 SPDX-Copyright: James Turner
3 SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6
7 #include "test_condition.hxx"
8
9 #include <simgear/props/condition.hxx>
10 #include <simgear/props/props.hxx>
11 #include <simgear/structure/exception.hxx>
12
13 #include <simgear/debug/logstream.hxx>
14
15 #include "test_suite/FGTestApi/testGlobals.hxx"
16
17 // Set up function for each test.
18 void SimgearConditionTests::setUp()
19 {
20 // Create a property tree.
21 tree = new SGPropertyNode;
22 }
23
24
25 // Clean up SimgearConditionTests each test.
26 void SimgearConditionTests::tearDown()
27 {
28 }
29
30
31 // Test property aliasing, to catch possible memory leaks.
32 void SimgearConditionTests::testEmptyCondition()
33 {
34 auto config = FGTestApi::propsFromString(R"(<?xml version="1.0" encoding="UTF-8"?>
35 <PropertyList>
36 <enabled>/foo/bar</enabled>
37 </PropertyList>
38 )");
39
40 sglog().setDeveloperMode(true);
41
42 CPPUNIT_ASSERT_THROW(sgReadCondition(tree, config->getChild("enabled")), sg_exception);
43
44 // repeat in non-developer mode; test the legacy behaviour
45 sglog().setDeveloperMode(false);
46
47 auto n2 = sgReadCondition(tree, config->getChild("enabled"));
48 CPPUNIT_ASSERT(n2);
49 CPPUNIT_ASSERT(n2->test());
50 }