Commit d953b8b

mo k <mo@mokhan.ca>
2012-02-18 18:04:18
start building table of function pointers to run each test.
1 parent 5eca8ef
Changed files (2)
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;
 }
practice
Binary file