From d953b8bc468c7f42c64448df02b482c51357425c Mon Sep 17 00:00:00 2001 From: mo k Date: Sat, 18 Feb 2012 11:04:18 -0700 Subject: start building table of function pointers to run each test. --- main.c | 20 +++++++++++++++++--- practice | Bin 9084 -> 9084 bytes 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 24ec67c..495f3ea 100644 --- a/main.c +++ b/main.c @@ -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; } diff --git a/practice b/practice index 4afc397..f947d45 100755 Binary files a/practice and b/practice differ -- cgit v1.2.3