X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftest.h;h=abd4e2aa4184f2babd6abc9ea1f14d86de925db6;hb=64e9fa38f42f0d30463da5ddc3a573619941d93a;hp=e92d9e23917b0a079f959d2a424fcd4bc4be5370;hpb=3645e647825396693c46a4de5d9e45dfde54dabd;p=m6w6%2Flibmemcached diff --git a/libtest/test.h b/libtest/test.h index e92d9e23..abd4e2aa 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -87,6 +87,7 @@ do \ return TEST_FAILURE; \ } \ } while (0) +#define test_true_hint test_true_got #define test_skip(A,B) \ do \ @@ -148,6 +149,8 @@ do \ } \ } while (0) +#define test_null test_zero + #define test_compare_got(__expected, __actual, __hint) \ do \ { \ @@ -158,6 +161,8 @@ do \ } \ } while (0) +#define test_compare_hint test_compare_got + #define test_compare_warn(__expected, __actual) \ do \ { \ @@ -186,9 +191,10 @@ do \ #define test_strcmp(A,B) \ do \ { \ - if (strcmp((A), (B))) \ + if ((A) == NULL or (B) == NULL or strcmp((A), (B))) \ { \ - fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \ + if ((B) == NULL) fprintf(stderr, "\n%s:%d: Expected %s, got \n", __FILE__, __LINE__, (A)); \ + else fprintf(stderr, "\n%s:%d: Expected %s, got \"%s\"\n", __FILE__, __LINE__, (A), (B)); \ libtest::create_core(); \ return TEST_FAILURE; \ } \ @@ -197,7 +203,7 @@ do \ #define test_memcmp(A,B,C) \ do \ { \ - if (memcmp((A), (B), (C))) \ + if ((A) == NULL or (B) == NULL or memcmp((A), (B), (C))) \ { \ fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \ libtest::create_core(); \ @@ -205,6 +211,17 @@ do \ } \ } while (0) +#define test_memcmp_hint(A,B,C,__hint) \ +do \ +{ \ + if ((A) == NULL or (B) == NULL or memcmp((A), (B), (C))) \ + { \ + fprintf(stderr, "\n%s:%d: (hint:%s) %.*s -> %.*s\n", __FILE__, __LINE__, __hint, (int)(C), (char *)(A), (int)(C), (char *)(B)); \ + libtest::create_core(); \ + return TEST_FAILURE; \ + } \ +} while (0) + #define test_return_if(__test_return_t) \ do \ { \