From 16331682b3430a194848ab2459a1b77b1436dc87 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 21 Feb 2016 18:04:49 +0000 Subject: easier debugging of ck_assert_strn_eq --- legacy/elm_code/src/tests/elm_code_suite.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/legacy/elm_code/src/tests/elm_code_suite.h b/legacy/elm_code/src/tests/elm_code_suite.h index fddba5bfcd..d541e9bea3 100644 --- a/legacy/elm_code/src/tests/elm_code_suite.h +++ b/legacy/elm_code/src/tests/elm_code_suite.h @@ -3,14 +3,16 @@ #include -#define ck_assert_strn_eq(str1, str2, len) \ +#define ck_assert_strn_eq(s1, s2, len) \ { \ - unsigned int i = 0; \ - while (i < len) \ - { \ - ck_assert_int_eq(*(str1 + i), *(str2 + i)); \ - i++; \ - } \ + char expected[len+1], actual[len+1]; \ +\ + strncpy(expected, s1, len); \ + expected[len] = '\0'; \ + strncpy(actual, s2, len); \ + actual[len] = '\0'; \ +\ + ck_assert_str_eq(expected, actual); \ } #include -- cgit v1.2.1