spek

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

commit a687900e183e5c0191b671e8c893f7153d713864
parent b51686a2d9c11f3b7e2698430392c0f34443dc91
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Mon, 27 Aug 2012 10:36:34 -0700

Add tests

Diffstat:
M.gitignore | 20++++++++++----------
MMakefile.am | 3++-
Mconfigure.ac | 1+
Atests/Makefile.am | 18++++++++++++++++++
Atests/test.c | 50++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 81 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,12 @@ +*.msi +*.o +*.xz *~ +.DS_Store +.deps +Makefile +Makefile.in +Makefile.in.in aclocal.m4 autom4te.cache compile @@ -7,36 +15,28 @@ configure data/spek.desktop data/spek.desktop.in depcomp -.deps dist/osx/Spek.app dist/osx/Spek.dmg dist/osx/spek.modules dist/win/spek.wxs -.DS_Store install-sh intltool-extract.in intltool-merge.in intltool-update.in libtool ltmain.sh -Makefile -Makefile.in -Makefile.in.in man/spek.1 missing mkinstalldirs -*.msi omf.make po/*.gmo po/.intltool-merge-cache po/POTFILES po/stamp-it samples/ -src/*.o -src/spek src/*.stamp +src/spek stamp-h1 -test* +tests/tests web/version xmldocs.make -*.xz diff --git a/Makefile.am b/Makefile.am @@ -2,7 +2,8 @@ SUBDIRS = \ data \ man \ po \ - src + src \ + tests EXTRA_DIST = \ intltool-extract.in \ diff --git a/configure.ac b/configure.ac @@ -69,6 +69,7 @@ AC_CONFIG_FILES([ man/spek.1 po/Makefile.in src/Makefile + tests/Makefile web/version ]) AC_OUTPUT diff --git a/tests/Makefile.am b/tests/Makefile.am @@ -0,0 +1,18 @@ +check_PROGRAMS = tests + +tests_SOURCES = \ + test.c + +tests_CPPFLAGS = \ + -include config.h \ + -I$(top_builddir)/src \ + -pthread + +tests_CFLAGS = \ + $(FFMPEG_CFLAGS) + +tests_LDADD = \ + $(FFMPEG_LIBS) + +tests_LDFLAGS = \ + -pthread diff --git a/tests/test.c b/tests/test.c @@ -0,0 +1,50 @@ +/* test.c + * + * 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/>. + */ + +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 <stdio.h> + +static char * test_minunit() +{ + mu_assert("Hello, MinUnit", 2 + 2 == 4); + 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; +}