forked from Arduino-CI/arduino_ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftwareserial.cpp
47 lines (36 loc) · 1.03 KB
/
softwareserial.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <ArduinoUnitTests.h>
#include <SoftwareSerial.h>
bool bigEndian = false;
bool flipLogic = false;
unittest(software_input_output)
{
GodmodeState* state = GODMODE();
state->reset();
SoftwareSerial ss(1, 2, flipLogic);
assertEqual(-1, ss.peek());
state->digitalPin[1].fromAscii("Holy crap ", bigEndian);
state->digitalPin[1].fromAscii("this took a lot of prep work", bigEndian);
assertFalse(ss.isListening());
assertEqual(-1, ss.peek());
ss.listen();
assertTrue(ss.isListening());
assertEqual(38, ss.available());
assertEqual('H', ss.peek());
assertEqual('H', ss.read());
assertEqual('o', ss.read());
assertEqual('l', ss.read());
assertEqual('y', ss.read());
ss.write('b');
ss.write('A');
ss.write('r');
assertEqual("bAr", state->digitalPin[2].toAscii(1, bigEndian));
}
unittest(print) {
GodmodeState* state = GODMODE();
state->reset();
SoftwareSerial ss(1, 2, flipLogic);
ss.listen();
ss.print(1.3, 2);
assertEqual("1.30", state->digitalPin[2].toAscii(1, bigEndian));
}
unittest_main()