From e757a6461dd7a4fd650e8b53a41dbc6407d3a3b7 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 17 Jul 2022 15:39:50 +0100 Subject: [PATCH] test.h: update to upstream 368c467 Signed-off-by: Yuxuan Shui --- subprojects/test.h/test.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/subprojects/test.h/test.h b/subprojects/test.h/test.h index 19327a4a..d2ec6bf6 100644 --- a/subprojects/test.h/test.h +++ b/subprojects/test.h/test.h @@ -78,6 +78,18 @@ struct test_file_metadata __attribute__((weak)) * test_file_head; } \ } while (0) +#define TEST_STRNEQUAL(a, b, len) \ + do { \ + if (strncmp(a, b, len) != 0) { \ + const char *part2 = " != " #b; \ + size_t len2 = len + strlen(part2) + 3; \ + char *buf = malloc(len2); \ + snprintf(buf, len2, "\"%.*s\"%s", len, a, part2); \ + SET_FAILURE(buf, true); \ + return; \ + } \ + } while (0) + #define TEST_CASE(_name) \ static void __test_h_##_name(struct test_case_metadata *, \ struct test_file_metadata *); \ @@ -191,5 +203,9 @@ static inline void __attribute__((constructor(102))) run_tests(void) { #define TEST_STREQUAL(a, b) \ (void)(a); \ (void)(b) +#define TEST_STRNEQUAL(a, b, len) \ + (void)(a); \ + (void)(b); \ + (void)(len) #endif