@@ -16,13 +16,18 @@ void test_parse_data(void) {
1616
1717 TEST_ASSERT_EQUAL (0 , logIndex);
1818
19+ servoManager.parseData (&data);
1920 servoManager.parseData (&data);
2021
21- TEST_ASSERT_EQUAL (2 , logIndex);
22+ TEST_ASSERT_EQUAL (4 , logIndex);
2223 TEST_ASSERT_EQUAL (0 , positions[0 ].servoId );
2324 TEST_ASSERT_EQUAL (375 , positions[0 ].position );
2425 TEST_ASSERT_EQUAL (1 , positions[1 ].servoId );
2526 TEST_ASSERT_EQUAL (375 , positions[1 ].position );
27+ TEST_ASSERT_EQUAL (0 , positions[2 ].servoId );
28+ TEST_ASSERT_EQUAL (376 , positions[2 ].position );
29+ TEST_ASSERT_EQUAL (1 , positions[3 ].servoId );
30+ TEST_ASSERT_EQUAL (376 , positions[3 ].position );
2631}
2732
2833void test_parse_data_without_line_breaks (void ) {
@@ -64,10 +69,48 @@ void test_move_all_towards_neutral(void) {
6469 TEST_ASSERT_TRUE (servoManager.servosAreAllNeutral ());
6570}
6671
72+ void test_servo_id_10_is_not_mixed_up_with_line_break (void ) {
73+ byte values[11 ] = {60 , 10 , 1 , 119 , 62 , 10 , 60 , 11 , 1 , 119 , 62 };
74+ AnimationData data (values, 11 );
75+ ServoManager servoManager;
76+ servoManager.setPositionCallback (move);
77+
78+ TEST_ASSERT_EQUAL (0 , logIndex);
79+
80+ servoManager.parseData (&data);
81+ servoManager.parseData (&data);
82+
83+ TEST_ASSERT_EQUAL (2 , logIndex);
84+ TEST_ASSERT_EQUAL (10 , positions[0 ].servoId );
85+ TEST_ASSERT_EQUAL (375 , positions[0 ].position );
86+ TEST_ASSERT_EQUAL (11 , positions[1 ].servoId );
87+ TEST_ASSERT_EQUAL (375 , positions[1 ].position );
88+ }
89+
90+ void test_start_and_end_characters_not_mixed_up_with_ids_and_position_values (void ) {
91+ byte values[11 ] = {60 , 60 , 0 , 60 , 62 , 10 , 60 , 62 , 0 , 62 , 62 };
92+ AnimationData data (values, 11 );
93+ ServoManager servoManager;
94+ servoManager.setPositionCallback (move);
95+
96+ TEST_ASSERT_EQUAL (0 , logIndex);
97+
98+ servoManager.parseData (&data);
99+ servoManager.parseData (&data);
100+
101+ TEST_ASSERT_EQUAL (2 , logIndex);
102+ TEST_ASSERT_EQUAL (60 , positions[0 ].servoId );
103+ TEST_ASSERT_EQUAL (60 , positions[0 ].position );
104+ TEST_ASSERT_EQUAL (62 , positions[1 ].servoId );
105+ TEST_ASSERT_EQUAL (62 , positions[1 ].position );
106+ }
107+
67108int main (int argc, char **argv) {
68109 UNITY_BEGIN ();
69110 RUN_TEST (test_parse_data);
70111 RUN_TEST (test_parse_data_without_line_breaks);
71112 RUN_TEST (test_move_all_towards_neutral);
113+ RUN_TEST (test_servo_id_10_is_not_mixed_up_with_line_break);
114+ RUN_TEST (test_start_and_end_characters_not_mixed_up_with_ids_and_position_values);
72115 UNITY_END ();
73116}
0 commit comments