From a6c8b4efa59628a755755c510aa9ee6db2728fb9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 8 Nov 2019 14:35:35 +0100 Subject: test: merge test_helpers.c and index.c No need to keep them separate. Originally I thought index.c was only going to contain the list of tests, but that didn't happen. --- test/tests.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/tests.h (limited to 'test/tests.h') diff --git a/test/tests.h b/test/tests.h new file mode 100644 index 0000000000..c19f90f75d --- /dev/null +++ b/test/tests.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include +#include + +#include "common/common.h" + +struct MPContext; + +bool run_tests(struct MPContext *mpctx); + +struct test_ctx { + struct mpv_global *global; + struct mp_log *log; +}; + +struct unittest { + // This is used to select the test on command line with --unittest=. + const char *name; + + // Cannot run without additional arguments supplied. + bool is_complex; + + // Entrypoints. There are various for various purposes. Only 1 of them must + // be set. + + // Entrypoint for tests which have a simple dependency on the mpv core. The + // core is sufficiently initialized at this point. + void (*run)(struct test_ctx *ctx); +}; + +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); -- cgit v1.2.3