mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
98b38b04c9
commit
a6c8b4efa5
|
@ -56,7 +56,7 @@
|
||||||
#include "demux/demux.h"
|
#include "demux/demux.h"
|
||||||
#include "misc/thread_tools.h"
|
#include "misc/thread_tools.h"
|
||||||
#include "sub/osd.h"
|
#include "sub/osd.h"
|
||||||
#include "test/index.h"
|
#include "test/tests.h"
|
||||||
#include "video/out/vo.h"
|
#include "video/out/vo.h"
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "audio/chmap.h"
|
#include "audio/chmap.h"
|
||||||
#include "audio/chmap_sel.h"
|
#include "audio/chmap_sel.h"
|
||||||
#include "index.h"
|
#include "tests.h"
|
||||||
#include "test_helpers.h"
|
|
||||||
|
|
||||||
#define LAYOUTS(...) (char*[]){__VA_ARGS__, NULL}
|
#define LAYOUTS(...) (char*[]){__VA_ARGS__, NULL}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "index.h"
|
#include "tests.h"
|
||||||
#include "test_helpers.h"
|
|
||||||
#include "video/out/gpu/video.h"
|
#include "video/out/gpu/video.h"
|
||||||
|
|
||||||
static void run(struct test_ctx *ctx)
|
static void run(struct test_ctx *ctx)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "index.h"
|
|
||||||
#include "misc/json.h"
|
#include "misc/json.h"
|
||||||
#include "misc/node.h"
|
#include "misc/node.h"
|
||||||
#include "test_helpers.h"
|
#include "tests.h"
|
||||||
|
|
||||||
struct entry {
|
struct entry {
|
||||||
const char *src;
|
const char *src;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "index.h"
|
|
||||||
#include "misc/linked_list.h"
|
#include "misc/linked_list.h"
|
||||||
#include "test_helpers.h"
|
#include "tests.h"
|
||||||
|
|
||||||
struct list_item {
|
struct list_item {
|
||||||
int v;
|
int v;
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "index.h"
|
|
||||||
#include "player/core.h"
|
#include "player/core.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
static const struct unittest *unittests[] = {
|
static const struct unittest *unittests[] = {
|
||||||
&test_chmap,
|
&test_chmap,
|
||||||
|
@ -55,3 +55,29 @@ bool run_tests(struct MPContext *mpctx)
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
static_assert(false, "don't define NDEBUG for tests");
|
static_assert(false, "don't define NDEBUG for tests");
|
||||||
#endif
|
#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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <float.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "common/common.h"
|
||||||
|
|
||||||
struct MPContext;
|
struct MPContext;
|
||||||
|
|
||||||
|
@ -30,3 +34,18 @@ extern const struct unittest test_chmap;
|
||||||
extern const struct unittest test_gl_video;
|
extern const struct unittest test_gl_video;
|
||||||
extern const struct unittest test_json;
|
extern const struct unittest test_json;
|
||||||
extern const struct unittest test_linked_list;
|
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);
|
|
@ -397,10 +397,9 @@ def build(ctx):
|
||||||
## Tests
|
## Tests
|
||||||
( "test/chmap.c", "tests" ),
|
( "test/chmap.c", "tests" ),
|
||||||
( "test/gl_video.c", "tests" ),
|
( "test/gl_video.c", "tests" ),
|
||||||
( "test/index.c", "tests" ),
|
|
||||||
( "test/json.c", "tests" ),
|
( "test/json.c", "tests" ),
|
||||||
( "test/linked_list.c", "tests" ),
|
( "test/linked_list.c", "tests" ),
|
||||||
( "test/test_helpers.c", "tests" ),
|
( "test/tests.c", "tests" ),
|
||||||
|
|
||||||
## Video
|
## Video
|
||||||
( "video/csputils.c" ),
|
( "video/csputils.c" ),
|
||||||
|
|
Loading…
Reference in New Issue