commit 36ba40797440913bbaa18d034979d19af373f1f7
parent 1f4683802de2474d51ae449f81cb3c52336e8fe1
Author: gearsix <gearsix@tuta.io>
Date: Thu, 16 Dec 2021 11:57:56 +0000
quick & dirty makefile; minor adjustments in test.c
Diffstat:
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,18 @@
+NAME=tralloc
+INC=$(NAME).h
+SRC=$(NAME).c
+OBJ=$(NAME).o
+CFLAGS=-Wall -ansi -pedantic
+
+all:
+ ${CC} $(CFLAGS) -c $(SRC)
+ ar -rc $(NAME).a $(OBJ)
+
+test:
+ rm -f test
+ ${CC} -Wall -pedantic -g -o test test.c tralloc.c
+ @./test
+
+clean:
+ rm -f $(NAME).a $(OBJ) test
+
diff --git a/test.c b/test.c
@@ -14,9 +14,8 @@ int main (int argc, char *argv[])
size_t siz;
char *str;
- printf("tr_siz: %lu\n", tr_siz());
+ printf("tr_siz: %lu, tr_limit: %lu\n", tr_siz(), tr_limit());
if (tr_siz() != 0) fail("initial tr_siz not 0\n");
- printf("tr_limit: %lu\n", tr_limit());
if (tr_limit() != 0) fail("initial tr_setlimit not 0\n");
siz = 6;
@@ -41,6 +40,8 @@ int main (int argc, char *argv[])
siz = 6;
tr_setlimit(10);
+ puts("the following should cause an assertion failure:");
+ fflush(stdout);
str = tr_calloc(2, siz); /* should cause assertion failure */
printf("str = '%s', %zu bytes\n", str, tr_allocsiz(str));
tr_free(str);