summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-02-18 11:04:18 -0700
committermo k <mo@mokhan.ca>2012-02-18 11:04:18 -0700
commitd953b8bc468c7f42c64448df02b482c51357425c (patch)
tree467ac2a2e92b4ae49aa6fbd8ad6dd289979d77ca
parent5eca8effb10dc1823bd675aefa0e3edf26cf994a (diff)
start building table of function pointers to run each test.
-rw-r--r--main.c20
-rwxr-xr-xpracticebin9084 -> 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
--- a/practice
+++ b/practice
Binary files differ