From 51c05fe7b5d6518bfb8a07ee3ec3c072bb21163e Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Fri, 3 Feb 2023 18:40:59 +0100 Subject: Initial commit --- test/Makefile | 21 +++++++++++++++++++++ test/main.c | 12 ++++++++++++ test/test.c | 14 ++++++++++++++ test/test.h | 8 ++++++++ test/test1.c | 32 ++++++++++++++++++++++++++++++++ test/test1.h | 9 +++++++++ 6 files changed, 96 insertions(+) create mode 100644 test/Makefile create mode 100644 test/main.c create mode 100644 test/test.c create mode 100644 test/test.h create mode 100644 test/test1.c create mode 100644 test/test1.h (limited to 'test') diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..5cc71c6 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,21 @@ +# See LICENSE file for copyright and license details. + +CC = cc +SRC != find * -name '*.c' +OBJ = ${SRC:.c=.o} + +CFLAGS = -Wall -ansi --std=c89 -pedantic\ + -I../src/ +LDFLAGS = -L../ -l:libstr.a + +tests: test-app + ./test-app + +.c.o: + ${CC} ${CFLAGS} -c $< -o $@ + +test-app: ${OBJ} + ${CC} ${LDFLAGS} -o $@ ${OBJ} + +clean: + rm -f ${test-app} ${OBJ} diff --git a/test/main.c b/test/main.c new file mode 100644 index 0000000..f6be903 --- /dev/null +++ b/test/main.c @@ -0,0 +1,12 @@ +/* See LICENSE file for copyright and license details. */ + +#include "test1.h" + +int +main(int argc, char **argv) +{ + test1(); + test2(); + + return 0; +} diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..a47adb6 --- /dev/null +++ b/test/test.c @@ -0,0 +1,14 @@ +/* See LICENSE file for copyright and license details. */ + +/* See LICENSE file for copyright and license details. */ + +#include +#include + +void +asserti(int expected, int value) +{ + if (expected != value) { + exit(1); + } +} diff --git a/test/test.h b/test/test.h new file mode 100644 index 0000000..cbd0a84 --- /dev/null +++ b/test/test.h @@ -0,0 +1,8 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef __TEST_H__ +#define __TEST_H__ + +void asserti(int, int); + +#endif /* __TEST_H__ */ diff --git a/test/test1.c b/test/test1.c new file mode 100644 index 0000000..777aa5f --- /dev/null +++ b/test/test1.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ + +#include +#include + +#include "test.h" + +void +test1(void) +{ + printf("executing test1... "); + asserti(0, strends("alexander", "xander")); + asserti(1, strends("alexander", "dander")); + asserti(1, strends("alexander", "alex")); + asserti(0, strends("alexander", "alexander")); + asserti(1, strends("dwm", "dwmdwm")); + + printf("OK\n"); +} + +void +test2(void) +{ + printf("executing test2... "); + asserti(0, strstarts("alexander", "alex")); + asserti(1, strstarts("alexander", "dalex")); + asserti(1, strstarts("alexander", "xander")); + asserti(0, strstarts("alexander", "alexander")); + asserti(1, strstarts("dwm", "dwmdwm")); + + printf("OK\n"); +} diff --git a/test/test1.h b/test/test1.h new file mode 100644 index 0000000..1b88561 --- /dev/null +++ b/test/test1.h @@ -0,0 +1,9 @@ +/* See LICENSE file for copyright and license details. */ + +#ifndef __TEST1_H__ +#define __TEST1_H__ + +void test1(void); +void test2(void); + +#endif /* __TEST1_H__ */ -- cgit v1.2.3