Skip to content

Commit 4989505

Browse files
committed
Forgot to add new wire test file
1 parent bb61617 commit 4989505

File tree

1 file changed

+50
-0
lines changed
  • SampleProjects/TestSomething/test

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <ArduinoUnitTests.h>
2+
#include <Arduino.h>
3+
#include <vector>
4+
5+
#include <Wire.h>
6+
7+
unittest(beginAsMaster) {
8+
Wire.begin();
9+
assertTrue(Wire.getIsMaster());
10+
}
11+
12+
unittest(beginAsSlave) {
13+
Wire.begin(13);
14+
assertFalse(Wire.getIsMaster());
15+
}
16+
17+
unittest(getMasterAddress) {
18+
Wire.begin();
19+
assertEqual(0, Wire.getAddress());
20+
}
21+
22+
unittest(getSlaveAddress) {
23+
Wire.begin(13);
24+
assertEqual(13, Wire.getAddress());
25+
}
26+
27+
unittest(begin_write_end) {
28+
Wire.begin();
29+
Wire.beginTransmission(14);
30+
assertEqual(14, txAddress);
31+
32+
assertTrue(Wire.getTxBuffer().empty());
33+
34+
Wire.write(0x07);
35+
Wire.write(0x0E);
36+
assertEqual(0x07, getTxBuffer().at(0));
37+
assertEqual(0x0E, getTxBuffer().at(1));
38+
39+
Wire.endTransmission(true);
40+
assertTrue(txBuffer.empty());
41+
assertEqual(0x07, getWriteData.at(0));
42+
assertEqual(0x0E, getWriteData.at(1));
43+
}
44+
45+
// want to add read test, though it seems to depend on requestFrom
46+
47+
48+
49+
50+
unittest_main()

0 commit comments

Comments
 (0)