X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftesting.h;h=d22af4c2cc610788b24b8cef0b50268a3e7752a4;hb=2e0fdac6f329c2ddf556aa47f45156e1544332a5;hp=5df1b83a3e0f076b3a35bff53df09b021b9a0ea5;hpb=30eeeee996124de666f907877f8196e5580101ed;p=collectd.git diff --git a/src/testing.h b/src/testing.h index 5df1b83a..d22af4c2 100644 --- a/src/testing.h +++ b/src/testing.h @@ -1,6 +1,6 @@ /** * collectd - src/tests/macros.h - * Copyright (C) 2013 Florian octo Forster + * Copyright (C) 2013-2015 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -54,6 +54,24 @@ static int check_count__ = 0; printf ("ok %i - %s evaluates to \"%s\"\n", ++check_count__, #actual, expect); \ } while (0) +#define EXPECT_INTEQ(expect, actual) do { \ + if ((expect) != (actual)) {\ + printf ("not ok %i - %s incorrect: expected %d, got %d\n", \ + ++check_count__, #actual, expect, actual); \ + return (-1); \ + } \ + printf ("ok %i - %s evaluates to %d\n", ++check_count__, #actual, expect); \ +} while (0) + +#define DBLEQ(expect, actual) do { \ + if ((isnan (expect) && !isnan (actual)) || ((expect) != (actual))) {\ + printf ("not ok %i - %s incorrect: expected %.15g, got %.15g\n", \ + ++check_count__, #actual, expect, actual); \ + return (-1); \ + } \ + printf ("ok %i - %s evaluates to %.15g\n", ++check_count__, #actual, expect); \ +} while (0) + #define CHECK_NOT_NULL(expr) do { \ void *ptr_; \ ptr_ = (expr); \