diff --git a/.gitignore b/.gitignore index b7bec58..0d3f186 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,6 @@ samples/ src/*.stamp src/spek stamp-h1 -tests/tests +tests/test web/version xmldocs.make diff --git a/tests/Makefile.am b/tests/Makefile.am index 373edba..dd16230 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,19 +1,21 @@ -TESTS = tests -check_PROGRAMS = tests +TESTS = \ + test -tests_SOURCES = \ - test.c +check_PROGRAMS = $(TESTS) -tests_CPPFLAGS = \ +noinst_HEADERS = \ + test.h + +AM_CPPFLAGS = \ -include config.h \ -I$(top_builddir)/src \ -pthread -tests_CFLAGS = \ +AM_CFLAGS = \ $(FFMPEG_CFLAGS) -tests_LDADD = \ +AM_LDADD = \ $(FFMPEG_LIBS) -tests_LDFLAGS = \ +AM_LDFLAGS = \ -pthread diff --git a/tests/test.c b/tests/test.c index a18389b..d2c628f 100644 --- a/tests/test.c +++ b/tests/test.c @@ -16,35 +16,11 @@ * along with Spek. If not, see . */ -static int tests_run; -#define mu_assert(message, test) do { if (!(test)) return message; } while (0) -#define mu_run_test(test) do { char *message = test(); tests_run++; \ - if (message) return message; } while (0) +#include "test.h" -#include - -static char * test_minunit() +int main() { - mu_assert("Hello, MinUnit", 2 + 2 == 4); + ensure(2 + 2 == 4, "Hello, tests!"); + return 0; } - -static char * all_tests() -{ - mu_run_test(test_minunit); - return 0; -} - -int main(int argc, char **argv) -{ - char *result = all_tests(); - if (result != 0) { - printf("%s\n", result); - } - else { - printf("ALL TESTS PASSED\n"); - } - printf("Tests run: %d\n", tests_run); - - return result != 0; -} diff --git a/tests/test.h b/tests/test.h new file mode 100644 index 0000000..49355b1 --- /dev/null +++ b/tests/test.h @@ -0,0 +1,34 @@ +/* test.h + * + * Copyright (C) 2012 Alexander Kojevnikov + * + * Spek is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Spek is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Spek. If not, see . + */ + +#ifndef TEST_H_ +#define TEST_H_ + +#include +#include +#include + +inline void ensure(bool test, const char *message) +{ + if (!test) { + printf("ERROR: %s\n", message); + exit(1); + } +} + +#endif