From 61cfda41f9443071bc84a7bf2b0dfd47951ca0a0 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Wed, 11 Dec 2013 16:50:36 +0100 Subject: tests/TypesTest: Add macro to compare memory regions Prints them out in case of failure --- tests/types/TypesTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp index ea9fdbeb..51aebeef 100644 --- a/tests/types/TypesTest.cpp +++ b/tests/types/TypesTest.cpp @@ -32,6 +32,16 @@ extern "C" { #include } +#define OSMO_ASSERT_MEM_EQ(a, b, size) \ + do { \ + if (memcmp(a, b, size)) { \ + printf("Data mismatch:\nGot:\t%s\n", \ + osmo_hexdump((const uint8_t *)a, size)); \ + printf("Want:\t%s\n", osmo_hexdump((const uint8_t *)b, size)); \ + OSMO_ASSERT(false); \ + } \ + } while (0) + #define OSMO_ASSERT_STR_EQ(a, b) \ do { \ if (strcmp(a, b)) { \ -- cgit v1.2.3