Skip to content
Snippets Groups Projects
Commit 374d2786 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Couple more tests for YAML parser

parent e6a6b8cb
No related branches found
No related tags found
1 merge request!260WIP: params autoconf
This commit is part of merge request !260. Comments created here will be created in the context of that merge request.
......@@ -125,8 +125,8 @@ void parserYAML::walkTreeR(YAML::Node n, vector<string>& tags, string hdr){
// cout << "SUBSTR " << str.substr(1,str.size() - 1);
walkTree(str.substr(1,str.size() - 1), tags, hdr);
}else{
std::copy(tags.begin(), tags.end(), std::ostream_iterator<string>(std::cout, "¬"));
cout << "«»" << n.Scalar() << endl;
// std::copy(tags.begin(), tags.end(), std::ostream_iterator<string>(std::cout, "¬"));
// cout << "«»" << n.Scalar() << endl;
_params.insert(pair<string,string>(hdr, n.Scalar()));
}
break;
......@@ -140,7 +140,7 @@ void parserYAML::walkTreeR(YAML::Node n, vector<string>& tags, string hdr){
}
case YAML::NodeType::Map : {
for(const auto& kv : n){
// If the key's value starts with a $ (i.e. $key) then its value is parsed as a literal map,
//If the key's value starts with a $ (i.e. $key) then its value is parsed as a literal map,
//otherwise the parser recursively parses the map
regex r("^\\$.*");
if(not regex_match(kv.first.as<string>(), r)){
......
......@@ -5,18 +5,35 @@
using namespace std;
using namespace wolf;
TEST(ParserYAML, RegularParse)
parserYAML parse(string _file)
{
string file = "";
file = "../test/params1.yaml";
parserYAML parser = parserYAML(file);
parserYAML parser = parserYAML(_file);
parser.parse();
return parser;
}
TEST(ParserYAML, RegularParse)
{
auto parser = parse("../test/params1.yaml");
auto params = parser.getParams();
for(auto it : params)
cout << it.first << " %% " << it.second << endl;
// for(auto it : params)
// cout << it.first << " %% " << it.second << endl;
ASSERT_EQ(params["odom/intrinsic/k_rot_to_rot"], "0.1");
ASSERT_EQ(params["processor1/sensorname"], "odom");
}
TEST(ParserYAML, ParseMap)
{
auto parser = parse("../test/params2.yaml");
auto params = parser.getParams();
ASSERT_EQ(params["processor1/mymap"], "[{k1:v1},{k2:v2},{k3:[v3,v4,v5]}]");
}
TEST(ParserYAML, JumpFile)
{
auto parser = parse("../test/params3.yaml");
auto params = parser.getParams();
ASSERT_EQ(params["my_proc_test/max_buff_length"], "100");
ASSERT_EQ(params["my_proc_test/jump/voting_active"], "false");
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
......
config:
sensors:
-
type: "ODOM 2D"
name: "odom"
intrinsic:
k_disp_to_disp: 0.1
k_rot_to_rot: 0.1
extrinsic:
pos: [1,2,3]
-
type: "RANGE BEARING"
name: "rb"
processors:
-
type: "ODOM 2D"
name: "processor1"
sensorname: "odom"
$mymap:
k1: v1
k2: v2
k3: [v3,v4,v5]
-
type: "RANGE BEARING"
name: "rb_processor"
sensorname: "rb"
-
type: "ODOM 2D"
name: "my_proc_test"
sensorname: "odom"
files:
- "/home/jcasals/workspace/wip/wolf/lib/libsensor_odo.so"
- "/home/jcasals/workspace/wip/wolf/lib/librange_bearing.so"
\ No newline at end of file
cov_det: 100
unmeasured_perturbation_std: 100
angle_turned: 100
dist_traveled: 100
max_buff_length: 100
max_time_span: 100
time_tolerance: 100
voting_active: false
\ No newline at end of file
config:
sensors:
-
type: "ODOM 2D"
name: "odom"
intrinsic:
k_disp_to_disp: 0.1
k_rot_to_rot: 0.1
extrinsic:
pos: [1,2,3]
-
type: "RANGE BEARING"
name: "rb"
processors:
-
type: "ODOM 2D"
name: "processor1"
sensorname: "odom"
-
type: "RANGE BEARING"
name: "rb_processor"
sensorname: "rb"
-
type: "ODOM 2D"
name: "my_proc_test"
sensorname: "odom"
follow: "../test/params3.1.yaml"
jump: "@../test/params3.1.yaml"
files:
- "/home/jcasals/workspace/wip/wolf/lib/libsensor_odo.so"
- "/home/jcasals/workspace/wip/wolf/lib/librange_bearing.so"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment