test
xml
test_if_unless.cpp
Go to the documentation of this file.
1
// Unit tests for if/unless attributes
2
// Author: Max Schwarz <max.schwarz@ais.uni-bonn.de>
3
4
#include <catch_ros/catch.hpp>
5
6
#include "../../src/launch/launch_config.h"
7
8
#include "
param_utils.h
"
9
10
using namespace
rosmon::launch
;
11
12
TEST_CASE
(
"if/unless basic"
,
"[if_unless]"
)
13
{
14
LaunchConfig
config;
15
config.
parseString
(R
"EOF(
16
<launch>
17
<param if="false" name="test_if" value="hello" />
18
<param if="true" name="test_if" value="world" />
19
20
<param if="1" name="test_if_number" value="hello" />
21
<param if="0" name="test_if_number" value="world" />
22
23
<param unless="false" name="test_unless" value="hello" />
24
<param unless="true" name="test_unless" value="world" />
25
</launch>
26
)EOF");
27
28
config.
evaluateParameters
();
29
30
CAPTURE(config.
parameters
());
31
32
auto
&
params
= config.
parameters
();
33
checkTypedParam<std::string>(
params
,
"/test_if"
,
XmlRpc::XmlRpcValue::TypeString
,
"world"
);
34
checkTypedParam<std::string>(
params
,
"/test_if_number"
,
XmlRpc::XmlRpcValue::TypeString
,
"hello"
);
35
checkTypedParam<std::string>(
params
,
"/test_unless"
,
XmlRpc::XmlRpcValue::TypeString
,
"hello"
);
36
}
37
38
TEST_CASE
(
"if/unless invalid"
,
"[if_unless]"
)
39
{
40
using
Catch::Matchers::Contains;
41
42
REQUIRE_THROWS_WITH(
43
LaunchConfig
().
parseString
(R
"EOF(<launch><param if="true" unless="true" name="test" value="test" /></launch>)EOF"),
44
Contains(
"if"
) && Contains(
"unless"
)
45
);
46
47
REQUIRE_THROWS_AS(
48
LaunchConfig
().
parseString
(R
"EOF(<launch><param if="unknown_value" name="test" value="test" /></launch>)EOF"),
49
ParseException
50
);
51
}
rosmon::launch::ParseException
Definition:
launch_config.h:32
rosmon::launch::LaunchConfig::parseString
void parseString(const std::string &input, bool onlyArguments=false)
Definition:
launch_config.cpp:249
param_utils.h
rosmon::launch::LaunchConfig
Definition:
launch_config.h:175
XmlRpc::XmlRpcValue::TypeString
TypeString
rosmon::launch
Definition:
bytes_parser.cpp:15
parseString
config parseString(R"EOF( <launch> <group ns="/"> <param name="param1" value="hello" /> </group> <node name="test_node" pkg="rosmon_core" type="abort" ns="/racecar"> <param name="private_param" value="hello again" /> </node> </launch> )EOF")
TEST_CASE
TEST_CASE("if/unless basic", "[if_unless]")
Definition:
test_if_unless.cpp:12
rosmon::launch::LaunchConfig::evaluateParameters
void evaluateParameters()
Definition:
launch_config.cpp:1185
rosmon::launch::LaunchConfig::parameters
const std::map< std::string, XmlRpc::XmlRpcValue > & parameters() const
Definition:
launch_config.h:212
params
auto & params
Definition:
test_param.cpp:226
rosmon_core
Author(s): Max Schwarz
autogenerated on Wed Feb 21 2024 04:01:14