Skip to content
Snippets Groups Projects
Unverified Commit 3058c8c6 authored by Gaëtan Harter's avatar Gaëtan Harter
Browse files

tests/periph_eeprom: use memcmp for cleared bytes

`strcmp` was used to check that the 4 bytes were empty but was not
testing what it should as an empty string is `0` bytes long.

The whole must be verified.
parent 7455e0b6
No related branches found
No related tags found
No related merge requests found
...@@ -246,15 +246,16 @@ static int cmd_test(int argc, char **argv) ...@@ -246,15 +246,16 @@ static int cmd_test(int argc, char **argv)
assert(eeprom_read_byte(EEPROM_SIZE / 2) == 'A'); assert(eeprom_read_byte(EEPROM_SIZE / 2) == 'A');
/* clear some bytes */ /* clear some bytes */
const uint8_t cleared[4] = {0, 0, 0, 0,};
eeprom_clear(0, 4); eeprom_clear(0, 4);
memset(result, 0, 4); memset(result, 0, 4);
ret = eeprom_read(0, (uint8_t *)result, 4); ret = eeprom_read(0, (uint8_t *)result, 4);
assert(strncmp(result, "", 4) == 0); assert(memcmp(result, cleared, 4) == 0);
assert(ret == 4); assert(ret == 4);
eeprom_clear(EEPROM_SIZE - 4, 4); eeprom_clear(EEPROM_SIZE - 4, 4);
ret = eeprom_read(EEPROM_SIZE - 4, (uint8_t *)result, 4); ret = eeprom_read(EEPROM_SIZE - 4, (uint8_t *)result, 4);
assert(strncmp(result, "", 4) == 0); assert(memcmp(result, cleared, 4) == 0);
assert(ret == 4); assert(ret == 4);
/* set some bytes */ /* set some bytes */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment