From 3058c8c64530deff4b15d7369c4f0f8169cfc3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de> Date: Tue, 12 Feb 2019 16:29:15 +0100 Subject: [PATCH] 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. --- tests/periph_eeprom/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/periph_eeprom/main.c b/tests/periph_eeprom/main.c index c56a008a95..a9af1709df 100644 --- a/tests/periph_eeprom/main.c +++ b/tests/periph_eeprom/main.c @@ -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 */ -- GitLab