9 #include "gmock/gmock.h"
10 #include "gtest/gtest.h"
12 #include <yarp/os/ResourceFinder.h>
20 using namespace testing;
22 using ::testing::InvokeArgument;
23 using ::testing::Matcher;
25 TEST(ServiceParserMultipleFT, check_settings_positive_001)
27 yarp::os::Bottle bottle;
28 bottle.fromString(
"(SETTINGS (ftPeriod 10) (enabledSensors fakeId) (temperaturePeriod 100) (useCalibration true) )");
34 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
38 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
39 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
42 TEST(ServiceParserMultipleFT, check_settings_positive_002)
44 yarp::os::Bottle bottle;
45 bottle.fromString(
"(SETTINGS (ftPeriod 10 20) (enabledSensors fakeId fakeId1) (temperaturePeriod 100 200) (useCalibration true false) )");
51 std::map<std::string ,
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}}};
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"));
61 TEST(ServiceParserMultipleFT, check_settings_negative_001)
63 yarp::os::Bottle bottle;
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) )");
74 TEST(ServiceParserMultipleFT, check_settings_negative_002)
76 yarp::os::Bottle bottle;
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) )");
87 TEST(ServiceParserMultipleFT, check_settings_negative_003)
89 yarp::os::Bottle bottle;
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) )");
100 TEST(ServiceParserMultipleFT, check_settings_negative_004)
102 yarp::os::Bottle bottle;
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 ) )");
113 TEST(ServiceParserMultipleFT, check_property_sensors_positive_001)
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"}}};
122 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0,
"fakeFrameName"}}};
126 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
127 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
130 TEST(ServiceParserMultipleFT, check_property_sensors_positive_002)
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"}}};
140 std::map<std::string ,
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"}}};
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"));
150 TEST(ServiceParserMultipleFT, check_property_sensors_positive_003)
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}}};
159 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
163 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
164 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
167 TEST(ServiceParserMultipleFT, check_property_sensors_positive_004)
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}}};
176 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
180 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
181 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
184 TEST(ServiceParserMultipleFT, check_property_sensors_positive_005)
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}}};
193 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain, 2, 13, 0, 0, 0, 0, 0}}};
197 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
198 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
201 TEST(ServiceParserMultipleFT, check_property_sensors_negative_001)
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}}};
210 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 0, 0, 0, 0, 0}}};
214 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
215 EXPECT_NE(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
218 TEST(ServiceParserMultipleFT, check_property_sensors_negative_002)
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}}};
230 TEST(ServiceParserMultipleFT, check_property_sensors_negative_003)
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}}};
242 TEST(ServiceParserMultipleFT, check_property_sensors_negative_004)
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}}};
254 TEST(ServiceParserMultipleFT, check_property_canboards_positive_001)
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}}};
263 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}}};
267 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
268 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
271 TEST(ServiceParserMultipleFT, check_property_canboards_positive_002)
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}}};
280 std::map<std::string ,
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}}};
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"));
290 TEST(ServiceParserMultipleFT, check_property_canboards_positive_003)
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}}};
299 std::map<std::string ,
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}}};
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"));
309 TEST(ServiceParserMultipleFT, check_property_canboards_positive_004)
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}}};
318 std::map<std::string ,
FtInfo> expected = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 2, 3, 4, 5, 6}}};
322 ASSERT_EQ(expected.size(), serviceParser.
ftInfo_.size());
323 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
ftInfo_.at(
"fakeId"));
326 TEST(ServiceParserMultipleFT, check_property_canboards_negative_001)
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}}};
335 std::map<std::string ,
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}}};
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"));
345 TEST(ServiceParserMultipleFT, check_property_canboards_negative_002)
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}}};
354 std::map<std::string ,
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}}};
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"));
364 TEST(ServiceParserMultipleFT, check_property_canboards_negative_003)
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}}};
373 std::map<std::string ,
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}}};
379 TEST(ServiceParserMultipleFT, check_checkCanMonitor_positive_001)
381 yarp::os::Bottle bottle;
382 bottle.fromString(
"(CANMONITOR (checkPeriod 101) (ratePeriod 200) (reportMode ALL) )");
390 eObrd_canmonitor_cfg_t expected = {101, eobrd_canmonitor_reportmode_ALL, 200};
394 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_001)
396 yarp::os::Bottle bottle;
397 bottle.fromString(
"(CANMONITOR (checkPeriod 101) (ratePeriod 200) (reportMode xxx) )");
406 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_002)
408 yarp::os::Bottle bottle;
409 bottle.fromString(
"(CANMONITOR (checkPeriod 300) (ratePeriod 200) (reportMode ALL) )");
418 TEST(ServiceParserMultipleFT, check_checkCanMonitor_negative_003)
420 yarp::os::Bottle bottle;
421 bottle.fromString(
"(CANMONITOR (checkPeriod 200) (ratePeriod 200000) (reportMode ALL) )");
430 TEST(ServiceParserMultipleFT, toEomn_positive_001)
432 FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 1, 13, 4, 5, 1, 2, 3};
434 eOas_ft_sensordescriptor_t
out;
437 eOas_ft_sensordescriptor_t expected = {{eobrd_strain2, {1, 2, 3}, {4, 5}}, {0, 13, eobrd_caninsideindex_none}, 0};
440 EXPECT_EQ(expected,
out);
443 TEST(ServiceParserMultipleFT, toEomn_positive_002)
445 FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 2, 13, 4, 5, 1, 2, 3};
447 eOas_ft_sensordescriptor_t
out;
450 eOas_ft_sensordescriptor_t expected = {{eobrd_strain2, {1, 2, 3}, {4, 5}}, {1, 13, eobrd_caninsideindex_none}, 0};
453 EXPECT_EQ(expected,
out);
456 TEST(ServiceParserMultipleFT, toEomn_negative_001)
458 FtInfo info = {10, 100, eoas_ft_mode_calibrated, eobrd_strain2, 3, 13, 4, 5, 1, 2, 3};
460 eOas_ft_sensordescriptor_t
out;
466 TEST(ServiceParserMultipleFT, checkBoardType_positive_001)
470 eObrd_type_t expected = eobrd_strain2;
475 TEST(ServiceParserMultipleFT, checkBoardType_positive_002)
479 eObrd_type_t expected = eobrd_strain;
484 TEST(ServiceParserMultipleFT, checkBoardType_positive_003)
488 eObrd_type_t expected = eobrd_strain2;
490 EXPECT_EQ(expected, serviceParser.
checkBoardType(
"eobrd_strain2"));
493 TEST(ServiceParserMultipleFT, checkBoardType_positive_004)
497 eObrd_type_t expected = eobrd_strain;
499 EXPECT_EQ(expected, serviceParser.
checkBoardType(
"eobrd_strain"));
502 TEST(ServiceParserMultipleFT, checkBoardType_negative_001)
506 eObrd_type_t expected = eobrd_unknown;
511 TEST(ServiceParserMultipleFT, checkBoardType_negative_002)
515 eObrd_type_t expected = eobrd_unknown;
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.
TEST(ServiceParserMultipleFT, check_settings_positive_001)