aboutsummaryrefslogtreecommitdiffstats
path: root/test_unit.c
blob: d19d6944f36d0dd71d166c6473a81484a698f432 (plain) (blame)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <assert.h>
#include <stdio.h>

#include "unit.h"


#define EPSILON (1e-7)

#define test(got, want) { \
	if (got < want-EPSILON || got > want+EPSILON) { \
		fprintf(stderr, "got %lf; want %lf\n", got, want); \
		assert(got == want); \
	} \
}


void
test_rad_per_sec(void) {
	test(rad_per_sec(123.456), 123.456);
}

void
test_deg_per_sec(void) {
	test(deg_per_sec(123.456), 2.15471367888);
}

void
test_rpm(void) {
	test(rpm(123.456), 12.92828207328);
}

void
test_as_rad_per_sec(void) {
	test(as_rad_per_sec(rad_per_sec(123.456)), 123.456);
}

void
test_as_deg_per_sec(void) {
	test(as_deg_per_sec(deg_per_sec(123.456)), 123.456);
}

void
test_as_rpm(void) {
	test(as_rpm(rpm(123.456)), 123.456);
}


void
test_cubic_centimetre(void) {
	assert(0);
}

void
test_litre(void) {
	assert(0);
}

void
test_cubic_metre(void) {
	assert(0);
}

void
test_cubic_inch(void) {
	assert(0);
}

void
test_as_cubic_centimetre(void) {
	assert(0);
}

void
test_as_litre(void) {
	assert(0);
}

void
test_as_cubic_metre(void) {
	assert(0);
}

void
test_as_cubic_inch(void) {
	assert(0);
}


int
main(void) {
	test_rad_per_sec();
	test_deg_per_sec();
	test_rpm();
	test_as_rad_per_sec();
	test_as_deg_per_sec();
	test_as_rpm();

	test_cubic_centimetre();
	test_litre();
	test_cubic_metre();
	test_cubic_inch();
	test_as_cubic_centimetre();
	test_as_litre();
	test_as_cubic_metre();
	test_as_cubic_inch();
}