9 #include <yarp/os/ResourceFinder.h>
14 #include "EoManagement.h"
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
24 using ::testing::InSequence;
25 using ::testing::InvokeArgument;
26 using ::testing::Matcher;
27 using ::testing::Pointee;
28 using ::testing::Return;
29 using ::testing::TypedEq;
30 using testing::internal::operator==;
34 yarp::os::Bottle bottle;
35 bottle.fromString(
"(SETTINGS (acquisitionRate 100) (enabledSensors fakeId) )");
41 std::map<std::string, BatteryInfo> expected = {{
"fakeId", {100, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
45 EXPECT_EQ(expected.at(
"fakeId"), serviceParser.
batteryInfo_);
50 yarp::os::Bottle bottle;
51 bottle.fromString(
"(SETTINGS (acquisitionRate 100) (enabledSensors) )");
62 yarp::os::Bottle bottle;
63 bottle.fromString(
"(SETTINGS (acquisitionRate) (enabledSensors fakeId) )");
74 yarp::os::Bottle bottle;
75 bottle.fromString(
"(XXX (acquisitionRate 100) (enabledSensors fakeId) )");
86 yarp::os::Bottle bottle;
87 bottle.fromString(
"(SETTINGS (xxx 100) (enabledSensors fakeId) )");
98 yarp::os::Bottle bottle;
99 bottle.fromString(
"(SETTINGS (acquisitionRate) (XXX fakeId) )");
111 yarp::os::Bottle bottle;
112 bottle.fromString(
"(SENSORS (id fakeId) (board bms) (location CAN2:13) )");
113 serviceParser.
batteryInfo_ = {100, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0};
117 BatteryInfo expected = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
127 yarp::os::Bottle bottle;
128 bottle.fromString(
"(SENSORS (id fakeId) (xxx bms) (location CAN2:13) )");
129 serviceParser.
batteryInfo_ = {100, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0};
139 yarp::os::Bottle bottle;
140 bottle.fromString(
"(SENSORS (id fakeId) (board bms) (xxx CAN2:13) )");
141 serviceParser.
batteryInfo_ = {100, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0};
151 yarp::os::Bottle bottle;
152 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
153 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
157 BatteryInfo expected = {100, eobrd_bms, 2, 13, 2, 3, 4, 5, 6};
167 yarp::os::Bottle bottle;
168 bottle.fromString(
"(CANBOARDS (xxx bms) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
169 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
179 yarp::os::Bottle bottle;
180 bottle.fromString(
"(CANBOARDS (type bms) (XXX (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
181 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
191 yarp::os::Bottle bottle;
192 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (xx 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
193 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
203 yarp::os::Bottle bottle;
204 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (xx 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
205 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
215 yarp::os::Bottle bottle;
216 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (minor 3) ) (xx (major 4) (minor 5) (build 6) ) )");
217 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
227 yarp::os::Bottle bottle;
228 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (xx 4) (minor 5) (build 6) ) )");
229 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
239 yarp::os::Bottle bottle;
240 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (xx 5) (build 6) ) )");
241 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
250 yarp::os::Bottle bottle;
251 bottle.fromString(
"(CANBOARDS (type bms) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (xx 6) ) )");
252 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
262 yarp::os::Bottle bottle;
263 bottle.fromString(
"(CANBOARDS (type xx) (PROTOCOL (major 2) (minor 3) ) (FIRMWARE (major 4) (minor 5) (build 6) ) )");
264 serviceParser.
batteryInfo_ = {100, eobrd_bms, 2, 13, 0, 0, 0, 0, 0};
274 eObrd_type_t expected = eobrd_bms;
282 eObrd_type_t expected = eobrd_bms;
284 EXPECT_NE(expected, serviceParser.
checkBoardType(
"eobrd_strain2"));
290 eObrd_type_t expected = eobrd_bms;
296 TEST(General, toEomn_positive_001) {
299 eOas_battery_sensordescriptor_t
out;
302 eOas_battery_sensordescriptor_t expected = {{eobrd_bms, {1, 2, 3}, {4, 5}}, {eOcanport1, 13, 2}};
305 EXPECT_EQ(expected,
out);
308 TEST(General, toEomn_negative_001) {
311 eOas_battery_sensordescriptor_t
out;
virtual bool checkSettings(const Bottle &settings)
virtual bool checkPropertySensors(const Bottle &property)
virtual eObrd_type_t checkBoardType(const std::string &boardType)
virtual bool checkPropertyCanBoards(const Bottle &bPropertiesCanBoards)
virtual bool checkSettings(const Bottle &settings)
TEST(ServiceParserCanBattery, check_settings_positive_001)