This repository was archived by the owner on Mar 25, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -28,4 +28,6 @@ void Ethernet_TC::renewDHCPLease() {
28
28
Ethernet.maintain ();
29
29
previous_lease = current_millis;
30
30
}
31
+
32
+ numAttemptedDHCPReleases++;
31
33
}
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ class Ethernet_TC {
13
13
IPAddress getIP () {
14
14
return IP;
15
15
};
16
+ int getNumAttemptedDHCPReleases () {
17
+ return numAttemptedDHCPReleases;
18
+ };
16
19
void renewDHCPLease ();
17
20
18
21
protected:
@@ -26,4 +29,7 @@ class Ethernet_TC {
26
29
IPAddress IP;
27
30
unsigned long previous_lease;
28
31
const unsigned long LEASE_INTERVAL = 345600000 ; // 4 days in milliseconds
32
+
33
+ // testing
34
+ int numAttemptedDHCPReleases = 0 ;
29
35
};
Original file line number Diff line number Diff line change 4
4
#include " Ethernet_TC.h"
5
5
6
6
unittest (test) {
7
- assertTrue (true );
7
+ // Test singleton
8
+ Ethernet_TC singleton1;
9
+ singleton1 = singleton1->getInstance ();
10
+ Ethernet_TC singleton2;
11
+ singleton2 = singleton2->getInstance ();
12
+ assertEqual (singleton1, singleton2);
13
+
14
+ // Test that the default Ip was used as a fall back
15
+ assertEqual (singleton->getIP (), " 19216812" );
16
+
17
+ // Test DHCP is being maintained
18
+ singleton1->renewDHCPLease ();
19
+ singleton1->renewDHCPLease ();
20
+ singleton1->renewDHCPLease ();
21
+ assertEqual (singleton1->getNumAttemptedDHCPReleases (), 3 );
8
22
}
9
23
10
24
unittest_main ()
You can’t perform that action at this time.
0 commit comments