-
Notifications
You must be signed in to change notification settings - Fork 18
/
unit.c
42 lines (33 loc) · 969 Bytes
/
unit.c
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
//
// unit.c
// Typing
//
// Created by Michael Dickens on 3/20/13.
//
#include <stdio.h>
#include "accessories.h"
#define PRINT_VERBOSE 0
/*
* Takes the expected value, the name of the function, and a list of arguments
* to the function. Calls the named function and passes its result into
* verify(). Passes in fun (converted to a string literal) as the message.
*/
#define VERIFY(expected, fun, ...) verify(expected, fun(__VA_ARGS__), #fun)
/*
* Compares expected to found. If they are not equal, prints an error message.
*/
int verify(int expected, int found, const char *message)
{
int res = (expected == found);
if (!res && PRINT_VERBOSE) printf("##### FAILURE: #####");
if (!res || PRINT_VERBOSE)
printf("%s: %d expected, %d found.\n", message, expected, found);
return res;
}
int main()
{
/* Initialize. */
setksize(K_NO);
/* TODO: Write some unit tests. */
return 0;
}