-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
unit.c
53 lines (38 loc) · 1.28 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
#include <check.h>
#include "led.h"
#include "syscalls.h"
START_TEST(it_opens_gpio_device_for_write) {
ck_assert_int_eq(mock_open_spy_numcalls(), 0);
ck_assert_str_eq(mock_open_spy_path(), "");
ck_assert_int_eq(mock_open_spy_oflag(), 0);
led_toggle();
ck_assert_int_eq(mock_open_spy_numcalls(), 1);
ck_assert_str_eq(mock_open_spy_path(), "/dev/gpio0");
ck_assert_int_eq(mock_open_spy_oflag(), O_WRONLY);
} END_TEST
START_TEST(it_stops_if_open_fails) {
} END_TEST
START_TEST(it_calls_ioctl_if_open_succeeds) {
} END_TEST
START_TEST(it_ioctls_gpio_device_to_toggle_our_pin) {
} END_TEST
START_TEST(it_closes_gpio_device_if_ioctl_succeeds) {
} END_TEST
START_TEST(it_closes_gpio_device_if_ioctl_fails) {
} END_TEST
void setup(void) {
mock_reset_all();
}
void teardown(void) {
}
TCase* tcase_unit(void) {
TCase *tc = tcase_create("Unit Tests");
tcase_add_checked_fixture(tc, setup, teardown);
tcase_add_test(tc, it_opens_gpio_device_for_write);
tcase_add_test(tc, it_stops_if_open_fails);
tcase_add_test(tc, it_calls_ioctl_if_open_succeeds);
tcase_add_test(tc, it_ioctls_gpio_device_to_toggle_our_pin);
tcase_add_test(tc, it_closes_gpio_device_if_ioctl_succeeds);
tcase_add_test(tc, it_closes_gpio_device_if_ioctl_fails);
return tc;
}