summaryrefslogtreecommitdiff
path: root/src/tests.c
blob: 5a1de16799456e7a601582eaf3586fa1791d1d4d (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
#include <stdio.h>
#include <string.h>
#include "reverse.h"
#include "assertions.h"

typedef int (*Test)();

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();
	}
}

void run_tests()
{
	Test tests[10] = {
		&test_string_reversal
	};

	run(tests);
}