X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftest.h;h=a79109f12f69ad298ae5ed7e4a1e6df9d48751a6;hb=35b7e1ac4af1f81704affd6fa94cac09603fdb35;hp=0f1e1e0ad7044846d0f1a60b99077e407850ade7;hpb=77e79fb2056c9a177a670da48178fd1ac051d33d;p=awesomized%2Flibmemcached diff --git a/libtest/test.h b/libtest/test.h index 0f1e1e0a..a79109f1 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -87,11 +87,21 @@ do \ return TEST_FAILURE; \ } \ } while (0) +#define test_true_hint test_true_got -#define test_skip(A,B) \ +#define test_skip(__expected, __actual) \ do \ { \ - if ((A) != (B)) \ + if (libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), false) == false) \ + { \ + return TEST_SKIPPED; \ + } \ +} while (0) + +#define test_skip_valgrind() \ +do \ +{ \ + if (libtest::_in_valgrind(__FILE__, __LINE__, __func__)) \ { \ return TEST_SKIPPED; \ } \ @@ -131,7 +141,7 @@ do \ #define test_compare(__expected, __actual) \ do \ { \ - if (not libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)))) \ + if (libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), true) == false) \ { \ libtest::create_core(); \ return TEST_FAILURE; \ @@ -160,10 +170,12 @@ do \ } \ } while (0) +#define test_compare_hint test_compare_got + #define test_compare_warn(__expected, __actual) \ do \ { \ - void(libtest::_compare(__FILE__, __LINE__, __func__, (__expected), (__actual))); \ + void(libtest::_compare(__FILE__, __LINE__, __func__, (__expected), (__actual)), true); \ } while (0) #define test_compare_warn_hint(__expected, __actual, __hint) \ @@ -188,9 +200,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; \ } \ @@ -199,7 +212,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(); \ @@ -207,6 +220,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 \ { \