mirror of
https://github.com/mpv-player/mpv
synced 2025-01-29 19:22:48 +00:00
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 "misc/thread_tools.h"
|
||||
#include "sub/osd.h"
|
||||
#include "test/index.h"
|
||||
#include "test/tests.h"
|
||||
#include "video/out/vo.h"
|
||||
|
||||
#include "core.h"
|
||||
|
@ -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}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 "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();
|
||||
}
|
||||
}
|
@ -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);
|
@ -397,10 +397,9 @@ def build(ctx):
|
||||
## Tests
|
||||
( "test/chmap.c", "tests" ),
|
||||
( "test/gl_video.c", "tests" ),
|
||||
( "test/index.c", "tests" ),
|
||||
( "test/json.c", "tests" ),
|
||||
( "test/linked_list.c", "tests" ),
|
||||
( "test/test_helpers.c", "tests" ),
|
||||
( "test/tests.c", "tests" ),
|
||||
|
||||
## Video
|
||||
( "video/csputils.c" ),
|
||||
|
Loading…
Reference in New Issue
Block a user