summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-07-01 14:32:21 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-07-01 14:32:21 +0200
commitaf70f178d8fe801d05fe83d00a09509834f4f65c (patch)
treed44c5fc05a544b10592db9701bfe32baf8181bbe /tests
parent554c9da1d6116eee356b45b579e5086ef66f21eb (diff)
downloadabaos-af70f178d8fe801d05fe83d00a09509834f4f65c.tar.gz
abaos-af70f178d8fe801d05fe83d00a09509834f4f65c.tar.bz2
added a strlcat
Diffstat (limited to 'tests')
-rw-r--r--tests/libc/Makefile29
-rw-r--r--tests/libc/test_strlcat.c19
2 files changed, 37 insertions, 11 deletions
diff --git a/tests/libc/Makefile b/tests/libc/Makefile
index 6b91c9b..8e0c01d 100644
--- a/tests/libc/Makefile
+++ b/tests/libc/Makefile
@@ -1,31 +1,38 @@
CC := gcc
CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror
-INCLUDES = -I../src
+INCLUDES = -I../../src/libc
LD := ld
all: test
-test_strlcpy: test_strlcpy.o ../src/string.o
- $(CC) -o test_strlcpy test_strlcpy.o ../src/string.o
+test_strlcpy: test_strlcpy.o ../../src/libc/string.o
+ $(CC) -o test_strlcpy test_strlcpy.o ../../src/libc/string.o
test_strlcpy.o: test_strlcpy.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o test_strlcpy.o test_strlcpy.c
-test_itoa: test_itoa.o ../src/stdlib.o ../src/string.o
- $(CC) -o test_itoa test_itoa.o ../src/stdlib.o ../src/string.o
+test_strlcat: test_strlcat.o ../../src/libc/string.o
+ $(CC) -o test_strlcat test_strlcat.o ../../src/libc/string.o
-test_itoa.o: test_itoa.c ../src/stdlib.o
+test_strlcat.o: test_strlcat.c
+ $(CC) $(CFLAGS) $(INCLUDES) -c -o test_strlcat.o test_strlcat.c
+
+test_itoa: test_itoa.o ../../src/libc/stdlib.o ../../src/libc/string.o
+ $(CC) -o test_itoa test_itoa.o ../../src/libc/stdlib.o ../../src/libc/string.o
+
+test_itoa.o: test_itoa.c ../../src/libc/stdlib.o
$(CC) $(CFLAGS) $(INCLUDES) -c -o test_itoa.o test_itoa.c
-../src/string.o: ../src/string.c
- $(CC) $(CFLAGS) -c -o ../src/string.o ../src/string.c
+../../src/libc/string.o: ../../src/libc/string.c
+ $(CC) $(CFLAGS) -c -o ../../src/libc/string.o ../../src/libc/string.c
-../src/stdlib.o: ../src/stdlib.c
+../../src/libc/stdlib.o: ../../src/libc/stdlib.c
$(CC) $(CFLAGS) -c -o ../src/stdlib.o ../src/stdlib.c
-test: test_strlcpy test_itoa
+test: test_strlcpy test_strlcat test_itoa
./test_strlcpy
+ ./test_strlcat
./test_itoa
clean:
- -rm -f test_strlcpy test_itoa *.o
+ -rm -f test_strlcpy test_strlcat test_itoa *.o
diff --git a/tests/libc/test_strlcat.c b/tests/libc/test_strlcat.c
new file mode 100644
index 0000000..074cb98
--- /dev/null
+++ b/tests/libc/test_strlcat.c
@@ -0,0 +1,19 @@
+#include "string.h"
+
+int main( void )
+{
+ char *s1 = "test_string";
+ char *s2 = "append";
+ char d[15];
+ size_t n;
+
+ *d = '\0';
+ n = strlcat( d, s1, 15 );
+ if( n != 11 ) return 1;
+ if( strcmp( d, s1 ) != 0 ) return 1;
+ n = strlcat( d, s2, 15 );
+ if( n != 14 ) return 1;
+ if( strcmp( d, "test_stringapp" ) != 0 ) return 1;
+
+ return 0;
+}