From 1fe50bdeeecacd0ca708cc5085cb9095b140a9ae Mon Sep 17 00:00:00 2001 From: UziMonkey Date: Tue, 30 Apr 2019 00:16:22 -0400 Subject: [PATCH] Added munit_assert_string_contains assertion --- munit.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/munit.h b/munit.h index 1d5672c..c157ec3 100644 --- a/munit.h +++ b/munit.h @@ -331,6 +331,18 @@ void munit_errorf_ex(const char* filename, int line, const char* format, ...); } while (0) \ MUNIT__POP_DISABLE_MSVC_C4127 +#define munit_assert_string_contains(a, b) \ + do { \ + const char* munit_tmp_a_ = a; \ + const char* munit_tmp_b_ = b; \ + if (MUNIT_UNLIKELY(strstr(munit_tmp_a_, munit_tmp_b_) == 0)) { \ + munit_errorf("assertion failed: strstr(%s,%s) strstr(\"%s\",\"%s\")", \ + #a, #b, munit_tmp_a_, munit_tmp_b_); \ + } \ + MUNIT__PUSH_DISABLE_MSVC_C4127 \ + } while (0) \ + MUNIT__POP_DISABLE_MSVC_C4127 + #define munit_assert_memory_equal(size, a, b) \ do { \ const unsigned char* munit_tmp_a_ = (const unsigned char*) (a); \