-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_ledcontrol.hpp
45 lines (33 loc) · 1.17 KB
/
test_ledcontrol.hpp
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
#include <iostream>
#include "./ledcontrol.hpp"
#include <assert.h>
int main() {
const ledcontrol::Parameters initial;
assert(initial.valid == false);
const auto on = ledcontrol::parse("true");
assert(on.valid == true);
assert(on.onpower == 255);
assert(on.period == -1);
const auto off = ledcontrol::parse("false");
assert(off.valid == true);
assert(off.onpower == 0);
assert(off.period == -1);
const auto pwm0 = ledcontrol::parse("0");
assert(pwm0.valid == true);
assert(pwm0.onpower == 0);
assert(pwm0.period == -1);
const auto pwm = ledcontrol::parse("40");
assert(pwm.valid == true);
assert(pwm.onpower == 40);
assert(pwm.period == -1);
const auto pwm255 = ledcontrol::parse("255");
assert(pwm255.valid == true);
assert(pwm255.onpower == 255);
assert(pwm255.period == -1);
const auto animfull = ledcontrol::parse("{ \"animate\": \"onoff\", \"on\": 255.0, \"off\": 1, \"period\": 300.0 }");
assert(animfull.valid == true);
assert(animfull.onpower == 255);
assert(animfull.offpower == 1);
assert(animfull.period == 300);
std::cout << "All tests passed" << std::endl;
}