iCub-main
testServiceParserMultipleFT.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  * Author: Luca Tricerri
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include "gmock/gmock.h"
10 #include "gtest/gtest.h"
11 
12 #include <yarp/os/ResourceFinder.h>
13 
14 #include <iostream>
15 #include <vector>
16 
18 #include "testUtils.h"
19 
20 using namespace testing;
21 using ::testing::_;
22 using ::testing::InvokeArgument;
23 using ::testing::Matcher;
24 
25 TEST(ServiceParserMultipleFT, check_settings_positive_001)
26 {
27  yarp::os::Bottle bottle;
28  bottle.fromString("(SETTINGS (ftPeriod 10) (enabledSensors fakeId) (temperaturePeriod 100) (useCalibration true) )");
29 
30  ServiceParserMultipleFt_mock serviceParser;
31 
32  bool ret = serviceParser.checkSettings(bottle);
33 
34  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
35 
36  EXPECT_TRUE(ret);
37 
38  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
39  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
40 }
41 
42 TEST(ServiceParserMultipleFT, check_settings_positive_002)
43 {
44  yarp::os::Bottle bottle;
45  bottle.fromString("(SETTINGS (ftPeriod 10 20) (enabledSensors fakeId fakeId1) (temperaturePeriod 100 200) (useCalibration true false) )");
46 
47  ServiceParserMultipleFt_mock serviceParser;
48 
49  bool ret = serviceParser.checkSettings(bottle);
50 
51  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}},
52  {"fakeId1", {20, 200, eoas_ft_mode_raw, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
53 
54  EXPECT_TRUE(ret);
55 
56  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
57  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
58  EXPECT_EQ(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
59 }
60 
61 TEST(ServiceParserMultipleFT, check_settings_negative_001)
62 {
63  yarp::os::Bottle bottle;
64  bottle.fromString(
65  "(SETTINGS (ftPeriod 10 20 30 40 50) (enabledSensors fakeId0 fakeId1 fakeId2 fakeId13 fakeId4 ) (temperaturePeriod 100 200 998 997 996) (useCalibration true false true true true) )");
66 
67  ServiceParserMultipleFt_mock serviceParser;
68 
69  bool ret = serviceParser.checkSettings(bottle);
70 
71  EXPECT_FALSE(ret);
72 }
73 
74 TEST(ServiceParserMultipleFT, check_settings_negative_002)
75 {
76  yarp::os::Bottle bottle;
77  bottle.fromString(
78  "(SETTINGS (ftPeriod 10 20 30 40) (enabledSensors fakeId0 fakeId1 fakeId2 fakeId13 fakeId4 ) (temperaturePeriod 100 200 998 997 996) (useCalibration true false true true true) )");
79 
80  ServiceParserMultipleFt_mock serviceParser;
81 
82  bool ret = serviceParser.checkSettings(bottle);
83 
84  EXPECT_FALSE(ret);
85 }
86 
87 TEST(ServiceParserMultipleFT, check_settings_negative_003)
88 {
89  yarp::os::Bottle bottle;
90  bottle.fromString(
91  "(SETTINGS (ftPeriod 10 20 30 40 50) (enabledSensors fakeId0 fakeId1 fakeId2 fakeId13 fakeId4 ) (temperaturePeriod 100 200 998 997) (useCalibration true false true true true) )");
92 
93  ServiceParserMultipleFt_mock serviceParser;
94 
95  bool ret = serviceParser.checkSettings(bottle);
96 
97  EXPECT_FALSE(ret);
98 }
99 
100 TEST(ServiceParserMultipleFT, check_settings_negative_004)
101 {
102  yarp::os::Bottle bottle;
103  bottle.fromString(
104  "(SETTINGS (ftPeriod 10 20 30 40 50) (enabledSensors fakeId0 fakeId1 fakeId2 fakeId13 fakeId4 ) (temperaturePeriod 100 200 998 997 996) (useCalibration true false true true ) )");
105 
106  ServiceParserMultipleFt_mock serviceParser;
107 
108  bool ret = serviceParser.checkSettings(bottle);
109 
110  EXPECT_FALSE(ret);
111 }
112 
113 TEST(ServiceParserMultipleFT, check_property_sensors_positive_001)
114 {
115  ServiceParserMultipleFt_mock serviceParser;
116  yarp::os::Bottle bottle;
117  bottle.fromString("(SENSORS (id fakeId) (board strain2) (location CAN2:13) (framename fakeFrameName) )");
118  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0, "fakeFrameName"}}};
119 
120  bool ret = serviceParser.checkPropertySensors(bottle);
121 
122  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0, "fakeFrameName"}}};
123 
124  EXPECT_TRUE(ret);
125 
126  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
127  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
128 }
129 
130 TEST(ServiceParserMultipleFT, check_property_sensors_positive_002)
131 {
132  ServiceParserMultipleFt_mock serviceParser;
133  yarp::os::Bottle bottle;
134  bottle.fromString("(SENSORS (id fakeId fakeId1) (board strain2 strain2) (location CAN2:13 CAN2:14) (framename fakeFrameName1 fakeFrameName2) )");
135  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0, "fakeFrameName1"}},
136  {"fakeId1", {20, 200, eoas_ft_mode_raw, eobrd_unknown, 2, 14, 0, 0, 0, 0, 0, "fakeFrameName2"}}};
137 
138  bool ret = serviceParser.checkPropertySensors(bottle);
139 
140  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0, "fakeFrameName1"}},
141  {"fakeId1", {20, 200, eoas_ft_mode_raw, eobrd_strain2, 2, 14, 0, 0, 0, 0, 0, "fakeFrameName2"}}};
142 
143  EXPECT_TRUE(ret);
144 
145  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
146  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
147  EXPECT_EQ(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
148 }
149 
150 TEST(ServiceParserMultipleFT, check_property_sensors_positive_003)
151 {
152  ServiceParserMultipleFt_mock serviceParser;
153  yarp::os::Bottle bottle;
154  bottle.fromString("(SENSORS (id fakeId fakeId1) (board strain2 strain2) (location CAN2:13 CAN2:14) )");
155  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
156 
157  bool ret = serviceParser.checkPropertySensors(bottle);
158 
159  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
160 
161  EXPECT_TRUE(ret);
162 
163  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
164  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
165 }
166 
167 TEST(ServiceParserMultipleFT, check_property_sensors_positive_004)
168 {
169  ServiceParserMultipleFt_mock serviceParser;
170  yarp::os::Bottle bottle;
171  bottle.fromString("(SENSORS (id fakeId) (board eobrd_strain2) (location CAN2:13) )");
172  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
173 
174  bool ret = serviceParser.checkPropertySensors(bottle);
175 
176  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
177 
178  EXPECT_TRUE(ret);
179 
180  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
181  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
182 }
183 
184 TEST(ServiceParserMultipleFT, check_property_sensors_positive_005)
185 {
186  ServiceParserMultipleFt_mock serviceParser;
187  yarp::os::Bottle bottle;
188  bottle.fromString("(SENSORS (id fakeId) (board eobrd_strain) (location CAN2:13) )");
189  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
190 
191  bool ret = serviceParser.checkPropertySensors(bottle);
192 
193  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 0, 0, 0, 0, 0}}};
194 
195  EXPECT_TRUE(ret);
196 
197  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
198  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
199 }
200 
201 TEST(ServiceParserMultipleFT, check_property_sensors_negative_001)
202 {
203  ServiceParserMultipleFt_mock serviceParser;
204  yarp::os::Bottle bottle;
205  bottle.fromString("(SENSORS (id fakeId) (board strain2) (location CAN2:14) )");
206  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
207 
208  bool ret = serviceParser.checkPropertySensors(bottle);
209 
210  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
211 
212  EXPECT_TRUE(ret);
213 
214  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
215  EXPECT_NE(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
216 }
217 
218 TEST(ServiceParserMultipleFT, check_property_sensors_negative_002)
219 {
220  ServiceParserMultipleFt_mock serviceParser;
221  yarp::os::Bottle bottle;
222  bottle.fromString("(SENSORS (id fakeId) (board strain2) (location CANx:15) )");
223  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
224 
225  bool ret = serviceParser.checkPropertySensors(bottle);
226 
227  EXPECT_FALSE(ret);
228 }
229 
230 TEST(ServiceParserMultipleFT, check_property_sensors_negative_003)
231 {
232  ServiceParserMultipleFt_mock serviceParser;
233  yarp::os::Bottle bottle;
234  bottle.fromString("(SENSORS (id fakeId fakeId1) (board strain2 strain2) (location CAN2:13 CAN2:14) )");
235  serviceParser.ftInfo_ = {{"notexistent", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {20, 200, eoas_ft_mode_raw, eobrd_unknown, 2, 14, 0, 0, 0, 0, 0}}};
236 
237  bool ret = serviceParser.checkPropertySensors(bottle);
238 
239  EXPECT_FALSE(ret);
240 }
241 
242 TEST(ServiceParserMultipleFT, check_property_sensors_negative_004)
243 {
244  ServiceParserMultipleFt_mock serviceParser;
245  yarp::os::Bottle bottle;
246  bottle.fromString("(SENSORS (id fakeId fakeId1) (board wrongBoard strain2) (location CAN2:13 CAN2:14) )");
247  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {20, 200, eoas_ft_mode_raw, eobrd_unknown, 2, 14, 0, 0, 0, 0, 0}}};
248 
249  bool ret = serviceParser.checkPropertySensors(bottle);
250 
251  EXPECT_FALSE(ret);
252 }
253 
254 TEST(ServiceParserMultipleFT, check_property_canboards_positive_001)
255 {
256  ServiceParserMultipleFt_mock serviceParser;
257  yarp::os::Bottle bottle;
258  bottle.fromString("(CANBOARDS (type strain2) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
259  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
260 
261  bool ret = serviceParser.checkPropertyCanBoards(bottle);
262 
263  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}}};
264 
265  EXPECT_TRUE(ret);
266 
267  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
268  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
269 }
270 
271 TEST(ServiceParserMultipleFT, check_property_canboards_positive_002)
272 {
273  ServiceParserMultipleFt_mock serviceParser;
274  yarp::os::Bottle bottle;
275  bottle.fromString("(CANBOARDS (type strain2) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
276  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 0, 0, 0, 0, 0}}};
277 
278  bool ret = serviceParser.checkPropertyCanBoards(bottle);
279 
280  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}},
281  {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 0, 0, 0, 0, 0}}};
282 
283  EXPECT_TRUE(ret);
284 
285  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
286  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
287  EXPECT_EQ(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
288 }
289 
290 TEST(ServiceParserMultipleFT, check_property_canboards_positive_003)
291 {
292  ServiceParserMultipleFt_mock serviceParser;
293  yarp::os::Bottle bottle;
294  bottle.fromString("(CANBOARDS (type strain2 strain) (PROTOCOL (major 2 7) (minor 3 8) ) (FIRMWARE (major 4 9) (minor 5 10) (build 6 11) ) )");
295  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 0, 0, 0, 0, 0}}};
296 
297  bool ret = serviceParser.checkPropertyCanBoards(bottle);
298 
299  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}},
300  {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 7, 8, 9, 10, 11}}};
301 
302  EXPECT_TRUE(ret);
303 
304  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
305  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
306  EXPECT_EQ(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
307 }
308 
309 TEST(ServiceParserMultipleFT, check_property_canboards_positive_004)
310 {
311  ServiceParserMultipleFt_mock serviceParser;
312  yarp::os::Bottle bottle;
313  bottle.fromString("(CANBOARDS (type eobrd_strain2) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
314  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
315 
316  bool ret = serviceParser.checkPropertyCanBoards(bottle);
317 
318  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}}};
319 
320  EXPECT_TRUE(ret);
321 
322  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
323  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
324 }
325 
326 TEST(ServiceParserMultipleFT, check_property_canboards_negative_001)
327 {
328  ServiceParserMultipleFt_mock serviceParser;
329  yarp::os::Bottle bottle;
330  bottle.fromString("(CANBOARDS (type strain2 strain) (PROTOCOL (major 2 7) (minor 3 8) ) (FIRMWARE (major 4 9) (minor 5 10) (build 6 11) ) )");
331  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0}}};
332 
333  bool ret = serviceParser.checkPropertyCanBoards(bottle);
334 
335  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}},
336  {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 7, 8, 9, 10, 11}}};
337 
338  EXPECT_TRUE(ret);
339 
340  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
341  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
342  EXPECT_NE(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
343 }
344 
345 TEST(ServiceParserMultipleFT, check_property_canboards_negative_002)
346 {
347  ServiceParserMultipleFt_mock serviceParser;
348  yarp::os::Bottle bottle;
349  bottle.fromString("(CANBOARDS (type strain2 strain) (PROTOCOL (major 2 7) (minor 3 8) ) (FIRMWARE (major 4 9) (minor 5 10) (build 6 20) ) )");
350  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0}}};
351 
352  bool ret = serviceParser.checkPropertyCanBoards(bottle);
353 
354  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}},
355  {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 7, 8, 9, 10, 11}}};
356 
357  EXPECT_TRUE(ret);
358 
359  ASSERT_EQ(expected.size(), serviceParser.ftInfo_.size());
360  EXPECT_EQ(expected.at("fakeId"), serviceParser.ftInfo_.at("fakeId"));
361  EXPECT_NE(expected.at("fakeId1"), serviceParser.ftInfo_.at("fakeId1"));
362 }
363 
364 TEST(ServiceParserMultipleFT, check_property_canboards_negative_003)
365 {
366  ServiceParserMultipleFt_mock serviceParser;
367  yarp::os::Bottle bottle;
368  bottle.fromString("(CANBOARDS (type wrongboardname strain) (PROTOCOL (major 2 7) (minor 3 8) ) (FIRMWARE (major 4 9) (minor 5 10) (build 6 20) ) )");
369  serviceParser.ftInfo_ = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}, {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 2, 13, 0, 0, 0, 0, 0}}};
370 
371  bool ret = serviceParser.checkPropertyCanBoards(bottle);
372 
373  std::map<std::string /*sensor id*/, FtInfo> expected = {{"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}},
374  {"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 7, 8, 9, 10, 11}}};
375 
376  EXPECT_FALSE(ret);
377 }
378 
379 TEST(ServiceParserMultipleFT, check_checkCanMonitor_positive_001)
380 {
381  yarp::os::Bottle bottle;
382  bottle.fromString("(CANMONITOR (checkPeriod 101) (ratePeriod 200) (reportMode ALL) )");
383 
384  ServiceParserMultipleFt_mock serviceParser;
385 
386  bool ret = serviceParser.checkCanMonitor(bottle);
387 
388  EXPECT_TRUE(ret);
389 
390  eObrd_canmonitor_cfg_t expected = {101, eobrd_canmonitor_reportmode_ALL, 200};
391  EXPECT_EQ(expected, serviceParser.canMonitor_);
392 }
393 
394 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_001)
395 {
396  yarp::os::Bottle bottle;
397  bottle.fromString("(CANMONITOR (checkPeriod 101) (ratePeriod 200) (reportMode xxx) )");
398 
399  ServiceParserMultipleFt_mock serviceParser;
400 
401  bool ret = serviceParser.checkCanMonitor(bottle);
402 
403  EXPECT_FALSE(ret);
404 }
405 
406 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_002)
407 {
408  yarp::os::Bottle bottle;
409  bottle.fromString("(CANMONITOR (checkPeriod 300) (ratePeriod 200) (reportMode ALL) )");
410 
411  ServiceParserMultipleFt_mock serviceParser;
412 
413  bool ret = serviceParser.checkCanMonitor(bottle);
414 
415  EXPECT_FALSE(ret);
416 }
417 
418 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_003)
419 {
420  yarp::os::Bottle bottle;
421  bottle.fromString("(CANMONITOR (checkPeriod 200) (ratePeriod 200000) (reportMode ALL) )");
422 
423  ServiceParserMultipleFt_mock serviceParser;
424 
425  bool ret = serviceParser.checkCanMonitor(bottle);
426 
427  EXPECT_FALSE(ret);
428 }
429 
430 TEST(ServiceParserMultipleFT, toEomn_positive_001)
431 {
432  FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 1, 13, 4, 5, 1, 2, 3};
433 
434  eOas_ft_sensordescriptor_t out;
435  bool res = info.toEomn(out);
436 
437  eOas_ft_sensordescriptor_t expected = {{eobrd_strain2, {1, 2, 3}, {4, 5}}, {0, 13, eobrd_caninsideindex_none}, 0};
438 
439  EXPECT_TRUE(res);
440  EXPECT_EQ(expected, out);
441 }
442 
443 TEST(ServiceParserMultipleFT, toEomn_positive_002)
444 {
445  FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 4, 5, 1, 2, 3};
446 
447  eOas_ft_sensordescriptor_t out;
448  bool res = info.toEomn(out);
449 
450  eOas_ft_sensordescriptor_t expected = {{eobrd_strain2, {1, 2, 3}, {4, 5}}, {1, 13, eobrd_caninsideindex_none}, 0};
451 
452  EXPECT_TRUE(res);
453  EXPECT_EQ(expected, out);
454 }
455 
456 TEST(ServiceParserMultipleFT, toEomn_negative_001)
457 {
458  FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 3, 13, 4, 5, 1, 2, 3};
459 
460  eOas_ft_sensordescriptor_t out;
461  bool res = info.toEomn(out);
462 
463  EXPECT_FALSE(res);
464 }
465 
466 TEST(ServiceParserMultipleFT, checkBoardType_positive_001)
467 {
468  ServiceParserMultipleFt_mock serviceParser;
469 
470  eObrd_type_t expected = eobrd_strain2;
471 
472  EXPECT_EQ(expected, serviceParser.checkBoardType("strain2"));
473 }
474 
475 TEST(ServiceParserMultipleFT, checkBoardType_positive_002)
476 {
477  ServiceParserMultipleFt_mock serviceParser;
478 
479  eObrd_type_t expected = eobrd_strain;
480 
481  EXPECT_EQ(expected, serviceParser.checkBoardType("strain"));
482 }
483 
484 TEST(ServiceParserMultipleFT, checkBoardType_positive_003)
485 {
486  ServiceParserMultipleFt_mock serviceParser;
487 
488  eObrd_type_t expected = eobrd_strain2;
489 
490  EXPECT_EQ(expected, serviceParser.checkBoardType("eobrd_strain2"));
491 }
492 
493 TEST(ServiceParserMultipleFT, checkBoardType_positive_004)
494 {
495  ServiceParserMultipleFt_mock serviceParser;
496 
497  eObrd_type_t expected = eobrd_strain;
498 
499  EXPECT_EQ(expected, serviceParser.checkBoardType("eobrd_strain"));
500 }
501 
502 TEST(ServiceParserMultipleFT, checkBoardType_negative_001)
503 {
504  ServiceParserMultipleFt_mock serviceParser;
505 
506  eObrd_type_t expected = eobrd_unknown;
507 
508  EXPECT_EQ(expected, serviceParser.checkBoardType("amcbldc"));
509 }
510 
511 TEST(ServiceParserMultipleFT, checkBoardType_negative_002)
512 {
513  ServiceParserMultipleFt_mock serviceParser;
514 
515  eObrd_type_t expected = eobrd_unknown;
516 
517  EXPECT_EQ(expected, serviceParser.checkBoardType(""));
518 }
Definition: ftInfo.h:17
eObrd_canmonitor_cfg_t canMonitor_
virtual eObrd_type_t checkBoardType(const std::string &boardType)
virtual bool checkCanMonitor(const Bottle &service)
virtual bool checkPropertyCanBoards(const Bottle &bPropertiesCanBoards)
virtual bool checkSettings(const Bottle &settings)
virtual bool checkPropertySensors(const Bottle &property)
std::map< std::string, FtInfo > ftInfo_
yarp::sig::Vector & map(yarp::sig::Vector &v, double(op)(double))
Performs a unary operator inplace on each element of a vector.
Definition: Math.cpp:305
out
Definition: sine.m:8
TEST(ServiceParserMultipleFT, check_settings_positive_001)