forked from emilybache/Parrot-Refactoring-Kata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParrotTest.c
78 lines (67 loc) · 2.36 KB
/
ParrotTest.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
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
#include <setjmp.h>
#include <stdarg.h>
#include <stdlib.h>
#include <cmocka.h>
#include "Parrot.h"
static void get_speed_of_european_parrot(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, EUROPEAN, 0, 0, false);
assert_float_equal(12.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_african_parrot_with_one_coconut(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, AFRICAN, 1, 0, false);
assert_float_equal(3.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_african_parrot_with_two_coconuts(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, AFRICAN, 2, 0, false);
assert_float_equal(0.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_african_parrot_with_no_coconuts(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, AFRICAN, 0, 0, false);
assert_float_equal(12.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_norwegian_blue_parrot_nailed(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, NORWEGIAN_BLUE, 0, 1.5, true);
assert_float_equal(0.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_norwegian_blue_parrot_not_nailed(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, NORWEGIAN_BLUE, 0, 1.5, false);
assert_float_equal(18.0, get_speed(&parrot), 0.0);
}
static void get_speed_of_norwegian_blue_parrot_not_nailed_high_voltage(void** state)
{
(void)state; /* unused */
Parrot parrot;
init_parrot(&parrot, NORWEGIAN_BLUE, 0, 4, false);
assert_float_equal(24.0, get_speed(&parrot), 0.0);
}
int main(void)
{
const struct CMUnitTest test_suite[] = {
cmocka_unit_test(get_speed_of_european_parrot), /* */
cmocka_unit_test(get_speed_of_african_parrot_with_one_coconut), /* */
cmocka_unit_test(get_speed_of_african_parrot_with_two_coconuts), /* */
cmocka_unit_test(get_speed_of_african_parrot_with_no_coconuts), /* */
cmocka_unit_test(get_speed_of_norwegian_blue_parrot_nailed), /* */
cmocka_unit_test(get_speed_of_norwegian_blue_parrot_not_nailed), /* */
cmocka_unit_test(get_speed_of_norwegian_blue_parrot_not_nailed_high_voltage), /* */
};
return cmocka_run_group_tests(test_suite, NULL, NULL);
}