forked from jandelgado/jled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_arduino_hal.cpp
32 lines (28 loc) · 905 Bytes
/
test_arduino_hal.cpp
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
// JLed Unit tests (run on host).
// Copyright 2017 Jan Delgado jdelgado@gmx.net
#include <arduino_hal.h> // NOLINT
#include "catch.hpp"
using jled::ArduinoHal;
TEST_CASE("first call to analogWrite() sets pin mode to OUTPUT",
"[araduino_hal]") {
arduinoMockInit();
constexpr auto kPin = 10;
auto h = ArduinoHal(kPin);
REQUIRE(arduinoMockGetPinMode(kPin) == 0);
h.analogWrite(123);
REQUIRE(arduinoMockGetPinMode(kPin) == OUTPUT);
}
TEST_CASE("analogWrite() writes correct value", "[araduino_hal]") {
arduinoMockInit();
constexpr auto kPin = 10;
auto h = ArduinoHal(kPin);
h.analogWrite(123);
REQUIRE(arduinoMockGetPinState(kPin) == 123);
}
TEST_CASE("millis() returns correct time", "[arduino_hal]") {
arduinoMockInit();
auto h = ArduinoHal(1);
REQUIRE(h.millis() == 0);
arduinoMockSetMillis(99);
REQUIRE(h.millis() == 99);
}