File tree 2 files changed +57
-0
lines changed
SampleProjects/TestSomething/test 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,55 @@ unittest(length)
10
10
assertEqual (EEPROM_SIZE, EEPROM.length ());
11
11
}
12
12
13
+ unittest (firstRead)
14
+ {
15
+ uint8_t a = EEPROM.read (0 );
16
+ assertEqual (255 , a);
17
+ }
18
+
19
+ unittest (writeRead)
20
+ {
21
+ EEPROM.write (0 , 24 );
22
+ uint8_t a = EEPROM.read (0 );
23
+ assertEqual (24 , a);
24
+
25
+ EEPROM.write (0 , 128 );
26
+ uint8_t b = EEPROM.read (0 );
27
+ assertEqual (128 , b);
28
+
29
+ // this will fail since it is out of bound (0 - 255)
30
+ EEPROM.write (0 , 256 );
31
+ uint8_t c = EEPROM.read (0 );
32
+ assertEqual (256 , c);
33
+
34
+ }
35
+
36
+ unittest (updateWrite)
37
+ {
38
+ EEPROM.write (1 , 14 );
39
+ EEPROM.update (1 , 22 );
40
+ uint8_t a = EEPROM.read (1 );
41
+ assertEqual (22 , a);
42
+ }
43
+
44
+ unittest (putGet)
45
+ {
46
+ const float f1 = 0 .025f ;
47
+ float f2 = 0 .0f ;
48
+ EEPROM.put (5 , f1);
49
+ assertEqual (0 .0f , f2);
50
+ EEPROM.get (5 , f2);
51
+ assertEqual (0 .025f , f2);
52
+ }
53
+
54
+ unittest (array)
55
+ {
56
+ int val = 10 ;
57
+ EEPROM[2 ] = val;
58
+ uint8_t a = EEPROM.read (2 );
59
+ assertEqual (10 , a);
60
+ }
61
+
13
62
#endif
14
63
15
64
unittest_main ()
Original file line number Diff line number Diff line change 3
3
#include < avr/io.h>
4
4
#include " WString.h"
5
5
#include " PinHistory.h"
6
+ #include " EEPROM.h"
6
7
7
8
// random
8
9
void randomSeed (unsigned long seed);
@@ -87,12 +88,19 @@ class GodmodeState {
87
88
spi.readDelayMicros = 0 ;
88
89
}
89
90
91
+ void resetEEPROM () {
92
+ for (int i = 0 ; i < EEPROM.length (); ++i){
93
+ EEPROM.update (i, 255 );
94
+ }
95
+ }
96
+
90
97
void reset () {
91
98
resetClock ();
92
99
resetPins ();
93
100
resetInterrupts ();
94
101
resetPorts ();
95
102
resetSPI ();
103
+ resetEEPROM ();
96
104
seed = 1 ;
97
105
}
98
106
You can’t perform that action at this time.
0 commit comments