@@ -38,22 +38,31 @@ test_init_spiral() {
3838 buffer .bytes = malloc (buffer .size );
3939 buffer .bytes = (uint8_t [2 ]){ 0b01101101 , 0b11000111 , };
4040 // build expected output struct
41- spiral_t expected = { .size = 16 , };
42- expected .lines = calloc (sizeof (line_t ), 16 );
43- direction_t directions [16 ] = {
44- UP , LEFT , DOWN , LEFT , DOWN , RIGHT , DOWN , RIGHT ,
45- UP , LEFT , UP , RIGHT , DOWN , RIGHT , UP , LEFT ,
41+ spiral_t expected = { .size = 17 , };
42+ expected .lines = calloc (sizeof (line_t ), 17 );
43+ direction_t directions [17 ] = {
44+ UP , RIGHT , UP , LEFT , UP , LEFT , DOWN , LEFT ,
45+ DOWN , RIGHT , UP , RIGHT , DOWN , LEFT , DOWN , RIGHT , UP
4646 };
47- for (uint8_t i = 0 ; i < 16 ; i ++ ) {
47+ for (uint8_t i = 0 ; i < 17 ; i ++ ) {
4848 expected .lines [i ].direction = directions [i ];
4949 }
5050
5151 // call init_spiral with buffer and store result
5252 spiral_t output = init_spiral (buffer );
5353
54+ if (output .size != expected .size ) {
55+ result = false;
56+ }
5457 // compare with expected struct
55- for (uint8_t i = 0 ; i < 16 ; i ++ ) {
58+ for (uint8_t i = 0 ; i < 17 ; i ++ ) {
5659 if (output .lines [i ].direction != expected .lines [i ].direction ) {
60+ printf (
61+ "%u: %i != %i\n" ,
62+ i ,
63+ output .lines [i ].direction ,
64+ expected .lines [i ].direction
65+ );
5766 result = false;
5867 }
5968 }
0 commit comments