ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=89cbb9daa0fe2811fe16da269982d6a9e3f54118

commit 89cbb9daa0fe2811fe16da269982d6a9e3f54118
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Feb 21 18:04:49 2016 +0000

    easier debugging of ck_assert_strn_eq
---
 elm_code/src/tests/elm_code_suite.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/elm_code/src/tests/elm_code_suite.h 
b/elm_code/src/tests/elm_code_suite.h
index fddba5b..d541e9b 100644
--- a/elm_code/src/tests/elm_code_suite.h
+++ b/elm_code/src/tests/elm_code_suite.h
@@ -3,14 +3,16 @@
 
 #include <check.h>
 
-#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 <Elm_Code.h>

-- 


Reply via email to