17 ASSERT_FAIL("%p != NULL", ptr); |
18 ASSERT_FAIL("%p != NULL", ptr); |
18 } |
19 } |
19 |
20 |
20 void assert_strcmp (const char *is, const char *should_be) |
21 void assert_strcmp (const char *is, const char *should_be) |
21 { |
22 { |
|
23 if (!should_be && !is) |
|
24 return; |
|
25 |
22 if (!is || strcmp(is, should_be)) |
26 if (!is || strcmp(is, should_be)) |
23 ASSERT_FAIL("%s != %s", dump_str(is), dump_str(should_be)); |
27 ASSERT_FAIL("%s != %s", dump_str(is), dump_str(should_be)); |
24 } |
28 } |
25 |
29 |
26 void assert_strncmp (const char *is, const char *should_be, size_t n) |
30 void assert_strncmp (const char *is, const char *should_be, size_t n) |
27 { |
31 { |
|
32 if (!should_be && !is) |
|
33 return; |
|
34 |
28 if (!is || strncmp(is, should_be, n)) |
35 if (!is || strncmp(is, should_be, n)) |
29 ASSERT_FAIL("%s:%u != %s", dump_strn(is, n), (unsigned) n, dump_strn(should_be, n)); |
36 ASSERT_FAIL("%s:%u != %s", dump_strn(is, n), (unsigned) n, dump_strn(should_be, n)); |
30 } |
37 } |
31 |
38 |
32 void assert_strlen (const char *str, size_t n) |
39 void assert_strlen (const char *str, size_t n) |