forked from Tordek/cheat
-
Notifications
You must be signed in to change notification settings - Fork 8
/
examples.c
47 lines (38 loc) · 942 Bytes
/
examples.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
43
44
45
46
47
#include <cheat.h>
#include <cheats.h>
#include <stddef.h>
#include <string.h>
CHEAT_DECLARE(
static char const yes[] = "yes";
static char const times = '*';
static int const thirteen = 13;
static char const equals = '=';
static double const a_lot = 1.21e+9;
)
CHEAT_TEST(confusing,
cheat_assert(times == thirteen);
cheat_assert(&equals == (char* )0xdead);
cheat_assert(sizeof *yes != sizeof times);
)
CHEAT_TEST(obvious,
cheat_assert_int(times, thirteen);
cheat_assert_pointer(&equals, (char* )0xdead);
cheat_assert_not_size(sizeof *yes, sizeof times);
)
CHEAT_DECLARE(
static double f(double const x) {
if (x < 0)
return -x;
return x;
}
)
CHEAT_TEST(tedious,
double const less = a_lot - thirteen;
cheat_assert(strcmp(yes, "no") == 0);
cheat_assert(f(a_lot - less) <= 1);
)
CHEAT_TEST(effortless,
double const less = a_lot - thirteen;
cheat_assert_string(yes, "no");
cheat_assert_double(a_lot, less, 1);
)