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
|
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "test.h"
test_main_group({
test_group("Things work", {
int x;
int y;
x = 1;
y = 2;
test_convey("X is one", {
test_debugf("A logged message.");
test_assert(x == 1);
});
test_convey("Y is two", {
test_so(y == 2);
y = 3;
test_so(y == 3);
});
test_convey("Operations (Outer)", {
test_convey("Arithmetic", {
test_so(y == 2);
test_convey("Addition", {
test_so(x + y == 3);
test_so(x + y + y == 5);
test_so(x == 9);
y = 5;
test_so(x + y == 6);
});
test_convey("Subtraction", {
test_so(x - y == -1);
test_so(y - x == 1);
});
});
});
test_convey("Middle test is skipped", {
test_convey("Start", {
test_so(1 == 1);
});
test_convey("Middle (Skip?)", {
test_so(9 - 1 == 8);
test_skip("forced skip");
test_so(0 == 1);
});
test_convey("Ending", {
test_so(2 == 2);
});
});
});
test_group("Second group", {
int x = 1;
static int y =1;
test_convey("x is 1", {
#ifndef _WIN32
sleep(1);
#endif
test_so(x == 1);
});
});
test_group("Reset group", {
static int x = 0;
static int y = 0;
test_reset({
x = 20;
});
test_convey("Add one to both y and x", {
x++;
y++;
test_so(x == 1); /* no reset yet */
test_so(y == 1);
});
test_convey("Again", {
x++;
y++;
test_so(x == 21);
test_so(y == 2);
});
test_convey("Third time", {
x++;
y++;
test_so(x == 21);
test_so(y == 3);
});
test_so(x == 20);
test_so(y == 3);
});
})
|