spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit e0de91bf8ef0284f8f2b496e2b1ebdb81777f509
parent a7b01a8f5516bda8919acc050996e5f725f34fc0
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Mon, 27 Aug 2012 22:33:44 -0700

Similify tests

Diffstat:
M.gitignore | 2+-
Mtests/Makefile.am | 18++++++++++--------
Mtests/test.c | 30+++---------------------------
Atests/test.h | 34++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 36 deletions(-)

diff --git 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 @@ -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 @@ -16,35 +16,11 @@ * along with Spek. If not, see <http://www.gnu.org/licenses/>. */ -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 <stdio.h> - -static char * test_minunit() +int main() { - mu_assert("Hello, MinUnit", 2 + 2 == 4); - return 0; -} + ensure(2 + 2 == 4, "Hello, tests!"); -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 @@ -0,0 +1,34 @@ +/* test.h + * + * Copyright (C) 2012 Alexander Kojevnikov <alexander@kojevnikov.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_H_ +#define TEST_H_ + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +inline void ensure(bool test, const char *message) +{ + if (!test) { + printf("ERROR: %s\n", message); + exit(1); + } +} + +#endif