diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 2 | ||||
-rw-r--r-- | test/Makefile | 15 | ||||
-rw-r--r-- | test/test-whitespace-input.c | 11 | ||||
-rwxr-xr-x | test/test.sh | 23 |
4 files changed, 51 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..2674822 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,2 @@ +test-whitespace-input +*.log diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..25c1690 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,15 @@ +CFLAGS += -I../ + +TESTS = \ + test-whitespace-input + +all: clean $(TESTS) + +test-whitespace-input: ../gate.o ../parser.o ../logic.o + +clean: + rm -f $(TESTS) + +.PHONY: test +test: + ./test.sh diff --git a/test/test-whitespace-input.c b/test/test-whitespace-input.c new file mode 100644 index 0000000..cb4ec22 --- /dev/null +++ b/test/test-whitespace-input.c @@ -0,0 +1,11 @@ +#include <assert.h> + +#include "gate.h" +#include "parser.h" + +int main(void) { + char test_string[] = "input b \n"; + parse_line(test_string); + assert(gate_get_input_by_name("b") != NULL); + return 0; +} diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..91dddbd --- /dev/null +++ b/test/test.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +fail="none" + +for i in test-* ; do + if [[ "$i" != *.* ]] ; then + echo -n "$i: " + if ./"$i" >"$i.stdout.log" 2>"$i.stderr.log" ; then + echo -e '[\e[0;32mPASS\e[0m]' + else + echo -e '[\e[1;31mFAIL\e[0m]' + fail="indeed" + fi + fi +done + +if [ "$fail" != "none" ] ; then + echo 'Test failure(s)' + exit 1 +else + echo Success + exit 0 +fi |