-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathadvanced.ino
81 lines (65 loc) · 1.62 KB
/
advanced.ino
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#line 2 "advanced.ino"
// Adapted from:
// https://github.com/mmurdoch/arduinounit/blob/master/examples/advanced/advanced.ino
#include <AUnit.h>
using namespace aunit;
test(simple1) {
assertTrue(true);
}
test(simple2) {
assertTrue(false);
}
class MyTestOnce: public TestOnce {
protected:
void setup() override {
n = random(6);
if (n == 0) skip();
}
int n;
};
testF(MyTestOnce, simple1) {
for (int i = -n; i <= n; ++i) {
for (int j = -n; j <= n; ++j) {
assertEqual(i+j, j+i);
}
}
}
class MyTestAgain: public TestAgain {
protected:
void setup() override {
TestAgain::setup();
when = random(100, 200);
}
long getValue() {
return 20L;
}
uint16_t when;
};
testingF(MyTestAgain, again) {
assertLess(getValue() ,50L);
if (millis() >= when) {
pass(); // if assertion is ok
}
}
//----------------------------------------------------------------------------
// setup() and loop()
//----------------------------------------------------------------------------
void setup() {
#if ! defined(EPOXY_DUINO)
delay(1000); // wait for stability on some boards to prevent garbage Serial
#endif
Serial.begin(115200); // ESP8266 default of 74880 not supported on Linux
while (!Serial); // for the Arduino Leonardo/Micro only
#if defined(EPOXY_DUINO)
Serial.setLineModeUnix();
#endif
//TestRunner::setVerbosity(Verbosity::kAll);
Serial.println(F("This test should produce the following:"));
Serial.println(
F("3 passed, 1 failed, 0 skipped, 0 timed out, out of 4 test(s).")
);
Serial.println(F("----"));
}
void loop() {
TestRunner::run();
}