-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFunctions.c
More file actions
55 lines (42 loc) · 1.28 KB
/
Copy pathtestFunctions.c
File metadata and controls
55 lines (42 loc) · 1.28 KB
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
46
47
48
49
50
51
52
53
54
55
#include "testFunctions.h"
#include "custom_defs.h"
#include <stdio.h>
void runTests(void (*test)(UBYTE stage, BOOL *done)) {
UBYTE stage;
BOOL done = NO;
for (stage = 0; !done; stage++)
test(stage, &done);
}
void printTestResult(char *testName, UBYTE stage, char *msg) {
printf("%s [%d]: ", testName, stage);
if (msg)
printf("FAILED - %s\n", msg);
else
printf("PASSED\n");
}
void expectStringIsNil(char *testName, UBYTE stage, String *result) {
char *msg = nil;
if (result)
msg = "expected result to be nil";
printTestResult(testName, stage, msg);
if (msg && result)
printf(" result: `%s`\n", CString(result));
}
void expectStringsAreEqual(char *testName, UBYTE stage, String *str,
String *result, String *expected) {
char *msg = nil;
if (!StringsAreEqual(result, expected))
msg = "expected strings to be equal";
printTestResult(testName, stage, msg);
if (msg) {
if (str)
printf(" test string: `%s`\n", CString(str));
if (result)
printf(" result: `%s`\n", CString(result));
if (expected)
printf(" expected: `%s`\n", CString(expected));
}
}
void expect(BOOL condition, char *testName, UBYTE stage, char *msg) {
printTestResult(testName, stage, condition ? nil : msg);
}