31 #include <gtest/gtest.h>
34 TEST(MotorMessageTest, motor_message_commandtype) {
50 TEST(MotorMessageTest, motor_message_commandtype_values) {
66 TEST(MotorMessageTest, motor_message_commandtype_invalid) {
73 TEST(MotorMessageTest, motor_message_commandtype_overflow) {
77 ASSERT_NE(0xFFFFFF, mc.
getType());
80 TEST(MotorMessageTest, motor_message_commandtype_neg) {
88 TEST(MotorMessageTest, motor_message_register) {
96 TEST(MotorMessageTest, motor_message_register_values) {
106 TEST(MotorMessageTest, motor_message_register_invalid) {
113 TEST(MotorMessageTest, motor_message_register_overflow) {
120 TEST(MotorMessageTest, motor_message_register_neg) {
128 TEST(MotorMessageTest, motor_message_data_64bit) {
132 ASSERT_EQ(0xABC, mc.
getData());
140 ASSERT_EQ(-0xABC, mc.
getData());
143 TEST(MotorMessageTest, motor_message_data_32bit) {
147 ASSERT_EQ(0xABC, mc.
getData());
155 ASSERT_EQ(-0xABC, mc.
getData());
158 TEST(MotorMessageTest, motor_message_data_16bit) {
162 ASSERT_EQ(0xABC, mc.
getData());
170 ASSERT_EQ(-0xABC, mc.
getData());
173 TEST(MotorMessageTest, motor_message_data_8bit) {
185 ASSERT_EQ(-0x50, mc.
getData());
188 TEST(MotorMessageTest, motor_message_serialize) {
194 RawMotorMessage expect = {0x7E, 0x3B, 0x2A, 0x00, 0x00, 0x01, 0x2C, 0x6D};
199 TEST(MotorMessageTest, motor_message_deserialize_good) {
203 RawMotorMessage input = {0x7E, 0x3B, 0x2A, 0x00, 0x00, 0x01, 0x2C, 0x6D};
211 TEST(MotorMessageTest, motor_message_deserialize_delimeter_in_data) {
214 RawMotorMessage input = {0x7E, 0x3B, 0x2A, 0x00, 0x00, 0x01, 0x7E, 0x1B};
222 TEST(MotorMessageTest, motor_message_deserialize_bad_delimeter) {
226 RawMotorMessage input = {0x67, 0x3B, 0x07, 0x00, 0x00, 0x00, 0x00, 0xBD};
231 TEST(MotorMessageTest, motor_message_deserialize_bad_protocol) {
235 RawMotorMessage input = {0x7E, 0x2B, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3D};
240 TEST(MotorMessageTest, motor_message_deserialize_bad_checksum) {
244 RawMotorMessage input = {0x7E, 0x3B, 0x07, 0x00, 0x00, 0x01, 0x2C, 0x0F};
249 TEST(MotorMessageTest, motor_message_deserialize_bad_type) {
253 RawMotorMessage input = {0x7E, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0xB9};
258 TEST(MotorMessageTest, motor_message_deserialize_bad_register) {
262 RawMotorMessage input = {0x7E, 0x3B, 0x60, 0x00, 0x00, 0x00, 0x2C, 0x38};
267 int main(
int argc,
char **argv) {
268 testing::InitGoogleTest(&argc, argv);
269 return RUN_ALL_TESTS();