diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/chmap.c | 3 | ||||
-rw-r--r-- | test/gl_video.c | 3 | ||||
-rw-r--r-- | test/json.c | 3 | ||||
-rw-r--r-- | test/linked_list.c | 3 | ||||
-rw-r--r-- | test/test_helpers.c | 29 | ||||
-rw-r--r-- | test/test_helpers.h | 24 | ||||
-rw-r--r-- | test/tests.c (renamed from test/index.c) | 28 | ||||
-rw-r--r-- | test/tests.h (renamed from test/index.h) | 21 |
8 files changed, 51 insertions, 63 deletions
diff --git a/test/chmap.c b/test/chmap.c index a489a7da61..91b1cf797f 100644 --- a/test/chmap.c +++ b/test/chmap.c @@ -1,7 +1,6 @@ #include "audio/chmap.h" #include "audio/chmap_sel.h" -#include "index.h" -#include "test_helpers.h" +#include "tests.h" #define LAYOUTS(...) (char*[]){__VA_ARGS__, NULL} diff --git a/test/gl_video.c b/test/gl_video.c index eb2288d8b4..556a81ac92 100644 --- a/test/gl_video.c +++ b/test/gl_video.c @@ -1,5 +1,4 @@ -#include "index.h" -#include "test_helpers.h" +#include "tests.h" #include "video/out/gpu/video.h" static void run(struct test_ctx *ctx) diff --git a/test/json.c b/test/json.c index 9997cdc892..e95f88c972 100644 --- a/test/json.c +++ b/test/json.c @@ -1,8 +1,7 @@ #include "common/common.h" -#include "index.h" #include "misc/json.h" #include "misc/node.h" -#include "test_helpers.h" +#include "tests.h" struct entry { const char *src; diff --git a/test/linked_list.c b/test/linked_list.c index 8daa854e9c..c9fbf9639e 100644 --- a/test/linked_list.c +++ b/test/linked_list.c @@ -1,7 +1,6 @@ #include "common/common.h" -#include "index.h" #include "misc/linked_list.h" -#include "test_helpers.h" +#include "tests.h" struct list_item { int v; diff --git a/test/test_helpers.c b/test/test_helpers.c deleted file mode 100644 index 187ff73c61..0000000000 --- a/test/test_helpers.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <inttypes.h> - -#include "test_helpers.h" - -void assert_int_equal_impl(const char *file, int line, int64_t a, int64_t b) -{ - if (a != b) { - printf("%s:%d: %"PRId64" != %"PRId64"\n", file, line, a, b); - abort(); - } -} - -void assert_string_equal_impl(const char *file, int line, - const char *a, const char *b) -{ - if (strcmp(a, b) != 0) { - printf("%s:%d: '%s' != '%s'\n", file, line, a, b); - abort(); - } -} - -void assert_float_equal_impl(const char *file, int line, - double a, double b, double tolerance) -{ - if (fabs(a - b) > tolerance) { - printf("%s:%d: %f != %f\n", file, line, a, b); - abort(); - } -} diff --git a/test/test_helpers.h b/test/test_helpers.h deleted file mode 100644 index 6ca3cd99b3..0000000000 --- a/test/test_helpers.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MP_TESTS_H -#define MP_TESTS_H - -#include <math.h> -#include <float.h> - -#include "common/common.h" - -#define assert_true(x) assert(x) -#define assert_false(x) assert(!(x)) -#define assert_int_equal(a, b) \ - assert_int_equal_impl(__FILE__, __LINE__, (a), (b)) -#define assert_string_equal(a, b) \ - assert_string_equal_impl(__FILE__, __LINE__, (a), (b)) -#define assert_float_equal(a, b, tolerance) \ - assert_float_equal_impl(__FILE__, __LINE__, (a), (b), (tolerance)) - -void assert_int_equal_impl(const char *file, int line, int64_t a, int64_t b); -void assert_string_equal_impl(const char *file, int line, - const char *a, const char *b); -void assert_float_equal_impl(const char *file, int line, - double a, double b, double tolerance); - -#endif diff --git a/test/index.c b/test/tests.c index 4804cead2f..68245d2df1 100644 --- a/test/index.c +++ b/test/tests.c @@ -1,5 +1,5 @@ -#include "index.h" #include "player/core.h" +#include "tests.h" static const struct unittest *unittests[] = { &test_chmap, @@ -55,3 +55,29 @@ bool run_tests(struct MPContext *mpctx) #ifdef NDEBUG static_assert(false, "don't define NDEBUG for tests"); #endif + +void assert_int_equal_impl(const char *file, int line, int64_t a, int64_t b) +{ + if (a != b) { + printf("%s:%d: %"PRId64" != %"PRId64"\n", file, line, a, b); + abort(); + } +} + +void assert_string_equal_impl(const char *file, int line, + const char *a, const char *b) +{ + if (strcmp(a, b) != 0) { + printf("%s:%d: '%s' != '%s'\n", file, line, a, b); + abort(); + } +} + +void assert_float_equal_impl(const char *file, int line, + double a, double b, double tolerance) +{ + if (fabs(a - b) > tolerance) { + printf("%s:%d: %f != %f\n", file, line, a, b); + abort(); + } +} diff --git a/test/index.h b/test/tests.h index 1564fe311a..c19f90f75d 100644 --- a/test/index.h +++ b/test/tests.h @@ -1,6 +1,10 @@ #pragma once -#include <stdbool.h> +#include <float.h> +#include <inttypes.h> +#include <math.h> + +#include "common/common.h" struct MPContext; @@ -30,3 +34,18 @@ extern const struct unittest test_chmap; extern const struct unittest test_gl_video; extern const struct unittest test_json; extern const struct unittest test_linked_list; + +#define assert_true(x) assert(x) +#define assert_false(x) assert(!(x)) +#define assert_int_equal(a, b) \ + assert_int_equal_impl(__FILE__, __LINE__, (a), (b)) +#define assert_string_equal(a, b) \ + assert_string_equal_impl(__FILE__, __LINE__, (a), (b)) +#define assert_float_equal(a, b, tolerance) \ + assert_float_equal_impl(__FILE__, __LINE__, (a), (b), (tolerance)) + +void assert_int_equal_impl(const char *file, int line, int64_t a, int64_t b); +void assert_string_equal_impl(const char *file, int line, + const char *a, const char *b); +void assert_float_equal_impl(const char *file, int line, + double a, double b, double tolerance); |