diff options
| author | mo k <mo@mokhan.ca> | 2012-02-18 11:04:18 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-02-18 11:04:18 -0700 |
| commit | d953b8bc468c7f42c64448df02b482c51357425c (patch) | |
| tree | 467ac2a2e92b4ae49aa6fbd8ad6dd289979d77ca | |
| parent | 5eca8effb10dc1823bd675aefa0e3edf26cf994a (diff) | |
start building table of function pointers to run each test.
| -rw-r--r-- | main.c | 20 | ||||
| -rwxr-xr-x | practice | bin | 9084 -> 9084 bytes |
2 files changed, 17 insertions, 3 deletions
@@ -15,16 +15,30 @@ int assert_equals(char *actual, char *expected) return ret == 0?1:0; } -void test_string_reversal() +int test_string_reversal() { char input[32]; strcpy( input, "tell The Truth"); reverse(input); - assert_equals(input, "hturT ehT llet"); + return assert_equals(input, "hturT ehT llet"); } +typedef int (*Test)(); + int main(int argc, const char *argv[]) { - test_string_reversal(); + int i; + Test tests[10] = {NULL}; + tests[0] = &test_string_reversal; + + for (i = 0; i < sizeof(tests); i++) { + Test test; + int result; + test = tests[i]; + if(NULL == test) break; + result = test(); + printf("%s \n",result == 1?"PASS":"FAIL"); + } + return 0; } Binary files differ |
