-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_power_button.c
47 lines (37 loc) · 1.23 KB
/
test_power_button.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 "catch.hpp"
#include "power_button.h"
#include <string.h>
SCENARIO("Power off tests", "[power_button]") {
GIVEN("the power is off") {
power_button_initialize(POWER_OFF);
WHEN("nothing happens") {
THEN("the power is still off") {
REQUIRE(power_button_getPowerState() == POWER_OFF);
}
}
WHEN("the power button is momentarily pressed") {
power_button_pressMomentary();
THEN("the power turns on") {
REQUIRE(power_button_getPowerState() == POWER_ON);
}
}
}
}
SCENARIO("Power on tests", "[power_button]") {
GIVEN("the power is on") {
power_button_initialize(POWER_OFF);
power_button_pressMomentary(); // Turn the power on.
WHEN("the power button is momentarily pressed") {
power_button_pressMomentary();
THEN("the power remains on") {
REQUIRE(power_button_getPowerState() == POWER_ON);
}
}
WHEN("the power button is held down") {
power_button_pressHold();
THEN("the power turns off") {
REQUIRE(power_button_getPowerState() == POWER_OFF);
}
}
}
}