X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftest.h;h=29959283ca1078b629689e6326427e50e5c6c117;hb=5ba03c8cc82605f0eb171d547876fb6cbed70a76;hp=58d24373ea8d17e3cf40c5b34ad366f69883fff1;hpb=c4dbc7e56b01545e25bc95ba122c79d4a2631a99;p=m6w6%2Flibmemcached diff --git a/libtest/test.h b/libtest/test.h index 58d24373..29959283 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -217,6 +217,37 @@ 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_skip(A,B) \ +do \ +{ \ + if ((A) != (B)) \ + { \ + return TEST_SKIPPED; \ + } \ +} 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 \ { \ @@ -248,6 +279,16 @@ do \ } \ } 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)