8#include <RobotsIO/Utils/Parameters.h>
9#include <RobotsIO/Utils/ParametersExtractor.h>
11#include <TestParameters.h>
34 std::cerr <<
"Expected field_0 to be -1, instead it is " << field0_ << std::endl;
39 std::cerr <<
"Expected field_1 to be M_PI, instead it is " << field1_ << std::endl;
44 std::cerr <<
"Expected field_2 to be true, instead it is " << (field2_ ?
"true" :
"false") << std::endl;
47 if (field3_ !=
"This is a string.")
49 std::cerr <<
"Expected field_3 to be 'This is a string.', instead it is " << field3_ << std::endl;
54 std::cerr <<
"Expected field_4 to be 1, instead it is " << field4_ << std::endl;
61 void extract_field(
const std::string& key,
const int& value)
override
66 void extract_field(
const std::string& key,
const double& value)
override
71 void extract_field(
const std::string& key,
const bool& value)
override
76 void extract_field(
const std::string& key,
const std::string& value)
override
81 void extract_field(
const std::string& key,
const std::size_t& value)
override
99int main(
int argc,
char** argv)
103 std::cout <<
"Setting parameters." << std::endl;
104 parameters.field0(-1);
105 parameters.field1(M_PI);
106 parameters.field2(
true);
107 parameters.field3(
"This is a string.");
108 parameters.field4(1);
110 std::cout <<
"Testing parameters using named accessors." << std::endl;
111 if (parameters.field0() != -1)
113 std::cerr <<
"Expected field_0 to be -1, instead it is " << parameters.field0() << std::endl;
116 if (parameters.field1() != M_PI)
118 std::cerr <<
"Expected field_1 to be M_PI, instead it is " << parameters.field1() << std::endl;
121 if (parameters.field2() !=
true)
123 std::cerr <<
"Expected field_2 to be true, instead it is " << (parameters.field2() ?
"true" :
"false") << std::endl;
126 if (parameters.field3() !=
"This is a string.")
128 std::cerr <<
"Expected field_3 to be 'This is a string.', instead it is " << parameters.field3() << std::endl;
131 if (parameters.field4() != 1)
133 std::cerr <<
"Expected field_4 to be 1, instead it is " << parameters.field4() << std::endl;
137 std::cout <<
"Testing parameters using extractor." << std::endl;
139 if (!(extraction_test.test()))