diff options
author | 2023-02-03 18:40:59 +0100 | |
---|---|---|
committer | 2023-02-03 18:40:59 +0100 | |
commit | 51c05fe7b5d6518bfb8a07ee3ec3c072bb21163e (patch) | |
tree | 92a52dc4849fbeb2566f8e87a88ff3ec02e5f75e /test | |
download | string2-51c05fe7b5d6518bfb8a07ee3ec3c072bb21163e.tar.gz string2-51c05fe7b5d6518bfb8a07ee3ec3c072bb21163e.zip |
Initial commit
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 21 | ||||
-rw-r--r-- | test/main.c | 12 | ||||
-rw-r--r-- | test/test.c | 14 | ||||
-rw-r--r-- | test/test.h | 8 | ||||
-rw-r--r-- | test/test1.c | 32 | ||||
-rw-r--r-- | test/test1.h | 9 |
6 files changed, 96 insertions, 0 deletions
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 <stdlib.h> +#include <stdio.h> + +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 <string2.h> +#include <stdio.h> + +#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__ */ |