mirror of
https://github.com/alexkay/spek.git
synced 2025-04-19 09:57:41 +03:00
Similify tests
This commit is contained in:
parent
a7b01a8f55
commit
e0de91bf8e
2
.gitignore
vendored
2
.gitignore
vendored
@ -38,6 +38,6 @@ samples/
|
||||
src/*.stamp
|
||||
src/spek
|
||||
stamp-h1
|
||||
tests/tests
|
||||
tests/test
|
||||
web/version
|
||||
xmldocs.make
|
||||
|
@ -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
|
||||
|
32
tests/test.c
32
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);
|
||||
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;
|
||||
}
|
||||
|
34
tests/test.h
Normal file
34
tests/test.h
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user