1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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.
This commit is contained in:
Gaëtan Harter 2019-02-12 16:29:15 +01:00
parent 7455e0b6fe
commit 3058c8c645
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -246,15 +246,16 @@ static int cmd_test(int argc, char **argv)
assert(eeprom_read_byte(EEPROM_SIZE / 2) == 'A');
/* clear some bytes */
const uint8_t cleared[4] = {0, 0, 0, 0,};
eeprom_clear(0, 4);
memset(result, 0, 4);
ret = eeprom_read(0, (uint8_t *)result, 4);
assert(strncmp(result, "", 4) == 0);
assert(memcmp(result, cleared, 4) == 0);
assert(ret == 4);
eeprom_clear(EEPROM_SIZE - 4, 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);
/* set some bytes */