Add tests

This commit is contained in:
Alexander Kojevnikov 2012-08-27 10:36:34 -07:00
parent b51686a2d9
commit a687900e18
5 changed files with 81 additions and 11 deletions

20
.gitignore vendored
View File

@ -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

View File

@ -2,7 +2,8 @@ SUBDIRS = \
data \
man \
po \
src
src \
tests
EXTRA_DIST = \
intltool-extract.in \

View File

@ -69,6 +69,7 @@ AC_CONFIG_FILES([
man/spek.1
po/Makefile.in
src/Makefile
tests/Makefile
web/version
])
AC_OUTPUT

18
tests/Makefile.am Normal file
View File

@ -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

50
tests/test.c Normal file
View File

@ -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;
}