blob: 44690fbc6810c86894b7d20ad3682c8be518aadf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "inc/reverse.h"
typedef int (*Test)();
int assert_equals(char *actual, char *expected)
{
int result = strcmp(actual, expected);
if(result != 0){
printf("FAIL! actual: '%s', expected: '%s'", actual, expected);
} else {
printf("PASS!");
}
return result == 0?1:0;
}
int test_string_reversal()
{
char input[32];
strcpy( input, "tell The Truth");
reverse(input);
return assert_equals(input, "hturT ehT llet");
}
void run(Test *tests)
{
int i;
for (i = 0; i < sizeof(tests); i++) {
Test test = tests[i];
if(NULL == test) break;
test();
}
}
int main(int argc, const char *argv[])
{
Test tests[10] = {
&test_string_reversal
};
run(tests);
return 0;
}
|