Fix strcmp check past end of file content

pull/96/head
Daniel Ludwig 7 years ago
parent c147744b72
commit 7d9581dd4c
  1. 3
      tests.c

@ -35,6 +35,7 @@
if(A){puts(" OK");tests_passed++;}\ if(A){puts(" OK");tests_passed++;}\
else{puts(" FAIL");tests_failed++;} else{puts(" FAIL");tests_failed++;}
#define STREQ(A, B) ((A) && (B) ? strcmp((A), (B)) == 0 : 0) #define STREQ(A, B) ((A) && (B) ? strcmp((A), (B)) == 0 : 0)
#define STRNEQ(A, B, N) ((A) && (B) ? strncmp((A), (B), (N)) == 0 : 0)
#define EPSILON 0.000001 #define EPSILON 0.000001
void test_suite_1(void); /* Test 3 files from json.org + serialization*/ void test_suite_1(void); /* Test 3 files from json.org + serialization*/
@ -512,7 +513,7 @@ void test_suite_9(void) {
file_contents = read_file(filename); file_contents = read_file(filename);
TEST(STREQ(file_contents, serialized)); TEST(STRNEQ(file_contents, serialized, serialization_size - 1));
} }
void test_suite_10(void) { void test_suite_10(void) {

Loading…
Cancel
Save