X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libtest%2Ftest.h;h=0493f3106b1b4b657aefb312d6195fb49a141af5;hb=f0b9c972a973d997db6660680938dd5acb2baa46;hp=b7a2f5eebf161549a01192e972212618c177cd25;hpb=b95041363ea69ccfb9eacb6bba1852814c32b4ee;p=awesomized%2Flibmemcached diff --git a/libtest/test.h b/libtest/test.h index b7a2f5ee..0493f310 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -217,6 +217,28 @@ do \ } \ } while (0) +#define test_compare(A,B) \ +do \ +{ \ + if ((A) != (B)) \ + { \ + fprintf(stderr, "\n%s:%d: Expected %s, got %lu\n", __FILE__, __LINE__, #A, (unsigned long)(B)); \ + create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) + +#define test_compare_got(A,B,C) \ +do \ +{ \ + if ((A) != (B)) \ + { \ + fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, #A, (C)); \ + create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) + #define test_false(A) \ do \ { \ @@ -242,12 +264,22 @@ do \ { \ if (strcmp((A), (B))) \ { \ - fprintf(stderr, "\n%s:%d: %s -> %s\n", __FILE__, __LINE__, (A), (B)); \ + fprintf(stderr, "\n%s:%d: `%s` -> `%s`\n", __FILE__, __LINE__, (A), (B)); \ create_core(); \ return TEST_FAILURE; \ } \ } while (0) +#define test_memcmp(A,B,C) \ +do \ +{ \ + if (memcmp((A), (B), (C))) \ + { \ + fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \ + create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x)