X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftesting.h;fp=src%2Ftesting.h;h=805449f7b933dad837f42b56137b613263e00fb8;hb=08a2128ac248150b50f9c54c9c71f573e54df3c3;hp=d22af4c2cc610788b24b8cef0b50268a3e7752a4;hpb=2e0fdac6f329c2ddf556aa47f45156e1544332a5;p=collectd.git diff --git a/src/testing.h b/src/testing.h index d22af4c2..805449f7 100644 --- a/src/testing.h +++ b/src/testing.h @@ -42,6 +42,7 @@ static int check_count__ = 0; #define OK1(cond, text) do { \ _Bool result = (cond); \ printf ("%s %i - %s\n", result ? "ok" : "not ok", ++check_count__, text); \ + if (!result) { return -1; } \ } while (0) #define OK(cond) OK1(cond, #cond) @@ -64,12 +65,17 @@ static int check_count__ = 0; } while (0) #define DBLEQ(expect, actual) do { \ - if ((isnan (expect) && !isnan (actual)) || ((expect) != (actual))) {\ + double e = (expect); double a = (actual); \ + if (isnan (e) && !isnan (a)) { \ printf ("not ok %i - %s incorrect: expected %.15g, got %.15g\n", \ - ++check_count__, #actual, expect, actual); \ + ++check_count__, #actual, e, a); \ + return (-1); \ + } else if (!isnan (e) && (((e-a) < -1e-12) || ((e-a) > 1e-12))) { \ + printf ("not ok %i - %s incorrect: expected %.15g, got %.15g\n", \ + ++check_count__, #actual, e, a); \ return (-1); \ } \ - printf ("ok %i - %s evaluates to %.15g\n", ++check_count__, #actual, expect); \ + printf ("ok %i - %s evaluates to %.15g\n", ++check_count__, #actual, e); \ } while (0) #define CHECK_NOT_NULL(expr) do { \