diff options
author | David Phillips <david@sighup.nz> | 2017-12-28 19:58:57 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-12-28 20:23:38 +1300 |
commit | 7823d9c7e4f3c0485e8d96e44e0d94541762c6d1 (patch) | |
tree | 38588863cbdfc5752bc9d6473f6809fc478bda97 /test | |
parent | 12fc1ad7e759715a11776298f6da6d946d75bbd1 (diff) | |
download | hence-7823d9c7e4f3c0485e8d96e44e0d94541762c6d1.tar.xz |
Move logic tests to test framework
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 6 | ||||
-rw-r--r-- | test/Makefile | 18 | ||||
-rw-r--r-- | test/test-logic-and.c | 10 | ||||
-rw-r--r-- | test/test-logic-nand.c | 10 | ||||
-rw-r--r-- | test/test-logic-nor.c | 10 | ||||
-rw-r--r-- | test/test-logic-not.c | 8 | ||||
-rw-r--r-- | test/test-logic-or.c | 10 | ||||
-rw-r--r-- | test/test-logic-xor.c | 10 |
8 files changed, 79 insertions, 3 deletions
diff --git a/test/.gitignore b/test/.gitignore index 2674822..04d77d8 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,2 +1,8 @@ +test-logic-and +test-logic-nand +test-logic-nor +test-logic-not +test-logic-or +test-logic-xor test-whitespace-input *.log diff --git a/test/Makefile b/test/Makefile index 25c1690..053552f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,14 +1,26 @@ CFLAGS += -I../ TESTS = \ - test-whitespace-input + test-whitespace-input \ + test-logic-and \ + test-logic-or \ + test-logic-nand \ + test-logic-nor \ + test-logic-xor \ + test-logic-not \ -all: clean $(TESTS) -test-whitespace-input: ../gate.o ../parser.o ../logic.o +all: $(TESTS) +test-%: test-%.c ../gate.o ../parser.o ../logic.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + +.PHONY: clean clean: rm -f $(TESTS) + for i in $(TESTS) ; do \ + rm -f $$i.std{out,err}.log ; \ + done .PHONY: test test: diff --git a/test/test-logic-and.c b/test/test-logic-and.c new file mode 100644 index 0000000..ce44ee8 --- /dev/null +++ b/test/test-logic-and.c @@ -0,0 +1,10 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_HIGH == logic_and(LOGIC_HIGH, LOGIC_HIGH)); + assert(LOGIC_LOW == logic_and(LOGIC_HIGH, LOGIC_LOW )); + assert(LOGIC_LOW == logic_and(LOGIC_LOW , LOGIC_HIGH)); + assert(LOGIC_LOW == logic_and(LOGIC_LOW , LOGIC_LOW )); +} diff --git a/test/test-logic-nand.c b/test/test-logic-nand.c new file mode 100644 index 0000000..ce44ee8 --- /dev/null +++ b/test/test-logic-nand.c @@ -0,0 +1,10 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_HIGH == logic_and(LOGIC_HIGH, LOGIC_HIGH)); + assert(LOGIC_LOW == logic_and(LOGIC_HIGH, LOGIC_LOW )); + assert(LOGIC_LOW == logic_and(LOGIC_LOW , LOGIC_HIGH)); + assert(LOGIC_LOW == logic_and(LOGIC_LOW , LOGIC_LOW )); +} diff --git a/test/test-logic-nor.c b/test/test-logic-nor.c new file mode 100644 index 0000000..20ddcb7 --- /dev/null +++ b/test/test-logic-nor.c @@ -0,0 +1,10 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_LOW == logic_nor(LOGIC_HIGH, LOGIC_HIGH)); + assert(LOGIC_LOW == logic_nor(LOGIC_HIGH, LOGIC_LOW )); + assert(LOGIC_LOW == logic_nor(LOGIC_LOW , LOGIC_HIGH)); + assert(LOGIC_HIGH == logic_nor(LOGIC_LOW , LOGIC_LOW )); +} diff --git a/test/test-logic-not.c b/test/test-logic-not.c new file mode 100644 index 0000000..a3a3e4d --- /dev/null +++ b/test/test-logic-not.c @@ -0,0 +1,8 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_HIGH == logic_not(LOGIC_LOW )); + assert(LOGIC_LOW == logic_not(LOGIC_HIGH)); +} diff --git a/test/test-logic-or.c b/test/test-logic-or.c new file mode 100644 index 0000000..7af3cbd --- /dev/null +++ b/test/test-logic-or.c @@ -0,0 +1,10 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_HIGH == logic_or(LOGIC_HIGH, LOGIC_HIGH)); + assert(LOGIC_HIGH == logic_or(LOGIC_HIGH, LOGIC_LOW )); + assert(LOGIC_HIGH == logic_or(LOGIC_LOW , LOGIC_HIGH)); + assert(LOGIC_LOW == logic_or(LOGIC_LOW , LOGIC_LOW )); +} diff --git a/test/test-logic-xor.c b/test/test-logic-xor.c new file mode 100644 index 0000000..9828ee9 --- /dev/null +++ b/test/test-logic-xor.c @@ -0,0 +1,10 @@ +#include <assert.h> + +#include "logic.h" + +int main(void) { + assert(LOGIC_LOW == logic_xor(LOGIC_HIGH, LOGIC_HIGH)); + assert(LOGIC_HIGH == logic_xor(LOGIC_HIGH, LOGIC_LOW )); + assert(LOGIC_HIGH == logic_xor(LOGIC_LOW , LOGIC_HIGH)); + assert(LOGIC_LOW == logic_xor(LOGIC_LOW , LOGIC_LOW )); +} |