1- #include "test-framework/unity.h"
21#include "secret_handshake.h"
2+ #include "test-framework/unity.h"
33#include <stdlib.h>
44
5- #define ARRAY_SIZE (arr ) (sizeof(arr) / sizeof(arr[0]))
5+ #define ARRAY_SIZE 4
6+
7+ #undef TEST_IGNORE
8+ #define TEST_IGNORE ()
69
710void setUp (void )
811{
@@ -14,72 +17,72 @@ void tearDown(void)
1417
1518static void test_commands_wink_for_1 (void )
1619{
17- const char * expected [] = { "wink" };
20+ const char * expected [] = { "wink" , NULL , NULL , NULL };
1821 const char * * actual = commands (1 );
19- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
22+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
2023 free (actual );
2124}
2225
2326static void test_commands_double_blink_for_10 (void )
2427{
2528 TEST_IGNORE (); // delete this line to run test
26- const char * expected [] = { "double blink" };
29+ const char * expected [] = { "double blink" , NULL , NULL , NULL };
2730 const char * * actual = commands (2 );
28- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
31+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
2932 free (actual );
3033}
3134
3235static void test_commands_close_your_eyes_for_100 (void )
3336{
3437 TEST_IGNORE ();
35- const char * expected [] = { "close your eyes" };
38+ const char * expected [] = { "close your eyes" , NULL , NULL , NULL };
3639 const char * * actual = commands (4 );
37- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
40+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
3841 free (actual );
3942}
4043
4144static void test_commands_jump_for_1000 (void )
4245{
4346 TEST_IGNORE ();
44- const char * expected [] = { "jump" };
47+ const char * expected [] = { "jump" , NULL , NULL , NULL };
4548 const char * * actual = commands (8 );
46- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
49+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
4750 free (actual );
4851}
4952
5053static void test_commands_combine_two_actions (void )
5154{
5255 TEST_IGNORE ();
53- const char * expected [] = { "wink" , "double blink" };
56+ const char * expected [] = { "wink" , "double blink" , NULL , NULL };
5457 const char * * actual = commands (3 );
55- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
58+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
5659 free (actual );
5760}
5861
5962static void test_commands_reverse_two_actions (void )
6063{
6164 TEST_IGNORE ();
62- const char * expected [] = { "double blink" , "wink" };
65+ const char * expected [] = { "double blink" , "wink" , NULL , NULL };
6366 const char * * actual = commands (19 );
64- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
67+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
6568 free (actual );
6669}
6770
6871static void test_commands_reversing_one_action_gives_the_same_action (void )
6972{
7073 TEST_IGNORE ();
71- const char * expected [] = { "jump" };
74+ const char * expected [] = { "jump" , NULL , NULL , NULL };
7275 const char * * actual = commands (24 );
73- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
76+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
7477 free (actual );
7578}
7679
7780static void test_commands_reversing_no_actions_still_gives_no_actions (void )
7881{
7982 TEST_IGNORE ();
80- const char * expected [] = { NULL };
83+ const char * expected [] = { NULL , NULL , NULL , NULL };
8184 const char * * actual = commands (16 );
82- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
85+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
8386 free (actual );
8487}
8588
@@ -89,7 +92,7 @@ static void test_commands_all_possible_actions(void)
8992 const char * expected [] = { "wink" , "double blink" , "close your eyes" ,
9093 "jump" };
9194 const char * * actual = commands (15 );
92- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
95+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
9396 free (actual );
9497}
9598
@@ -99,16 +102,16 @@ static void test_commands_reverse_all_possible_actions(void)
99102 const char * expected [] = { "jump" , "close your eyes" , "double blink" ,
100103 "wink" };
101104 const char * * actual = commands (31 );
102- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
105+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
103106 free (actual );
104107}
105108
106109static void test_commands_do_nothing_for_zero (void )
107110{
108111 TEST_IGNORE ();
109- const char * expected [] = { NULL };
112+ const char * expected [] = { NULL , NULL , NULL , NULL };
110113 const char * * actual = commands (0 );
111- TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE ( expected ) );
114+ TEST_ASSERT_EQUAL_STRING_ARRAY (expected , actual , ARRAY_SIZE );
112115 free (actual );
113116}
114117
0 commit comments