12 char dataOffset = ((__TIME__)[3] -
'0')*5 + (__TIME__)[7] -
'0';
17 static void setUp(
void) {
21 static void tearDown(
void) {
25 static void test_Warning(
void) {
26 printf(
"---------------------------------------------\r\n");
27 printf(
"Warning: This test suite mangles your EEPROM!\r\n");
31 printf(
"Current dataOffset: %i\r\n",
dataOffset);
33 printf(
"---------------------------------------------\r\n");
36 static void test_SingleByteReadWrite(
void) {
41 TEST_ASSERT_TRUE(mem.
Put(address, data));
42 TEST_ASSERT_EQUAL_HEX8(data, mem.
Get(address));
64 static void test_PageWriteSingleByteRead(
void) {
72 data[size - 1] = result;
73 TEST_ASSERT_TRUE(mem.
Put(address, data, size));
74 TEST_ASSERT_EQUAL_INT(result, mem.
Get(address));
75 TEST_ASSERT_EQUAL_INT(result, mem.
Get(address + size - 1));
78 static void test_PageReadWrite(
void) {
92 TEST_ASSERT_TRUE(mem.
Put(address, output, size));
93 mem.
Get(address, input, size);
94 TEST_ASSERT_EQUAL_MEMORY(output, input, size);
98 static void test_PageReadDoesntBufferOverflow(
void) {
104 char input [size * 2];
105 char overflowPattern [size];
106 for (
int i = 0; i < size; ++i) {
107 input[i + size] = overflowPattern[i] = 0x83 +
dataOffset;
110 mem.
Put(address, output, size);
111 mem.
Get(address, input, size);
112 TEST_ASSERT_EQUAL_MEMORY(overflowPattern, input + size, size);
115 static void test_PutGetInt(
void) {
123 TEST_ASSERT_EQUAL_INT(bytes, mem.
GetNumber(address, size));
127 static void test_PutGetShort(
void) {
135 TEST_ASSERT_EQUAL_INT(bytes, mem.
GetNumber(address, size));