From 2860df435bc0ec1601bf2e7eedacc63258b932aa Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 10 Feb 2005 22:00:31 +0000 Subject: [PATCH] Added tests for the mempool string functions. --- lib/Makefile | 3 ++- lib/mempool-fmt.c | 4 ++-- lib/mempool-str.c | 15 +++++++++++++++ lib/mempool.t | 7 +++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 lib/mempool.t diff --git a/lib/Makefile b/lib/Makefile index c2d3e485..deb40b0b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -51,10 +51,11 @@ obj/lib/redblack-test: obj/lib/redblack-test.o $(LIBUCW) obj/lib/binheap-test: obj/lib/binheap-test.o $(LIBUCW) obj/lib/lizard-test: obj/lib/lizard-test.o $(LIBUCW) -TESTS+=$(addprefix obj/lib/,regex.test unicode-utf8.test hash-test.test) +TESTS+=$(addprefix obj/lib/,regex.test unicode-utf8.test hash-test.test mempool.test) obj/lib/regex.test: obj/lib/regex-t obj/lib/unicode-utf8.test: obj/lib/unicode-utf8-t obj/lib/hash-test.test: obj/lib/hash-test +obj/lib/mempool.test: obj/lib/mempool-fmt-t obj/lib/mempool-str-t ifdef CONFIG_UCW_PERL include lib/perl/Makefile diff --git a/lib/mempool-fmt.c b/lib/mempool-fmt.c index 47bb71eb..c8b1e4c8 100644 --- a/lib/mempool-fmt.c +++ b/lib/mempool-fmt.c @@ -66,9 +66,9 @@ mp_printf(struct mempool *p, char *fmt, ...) int main(void) { struct mempool *mp = mp_new(64); - char *x = mp_printf(mp, "Hello, %s!\n", "World"); + char *x = mp_printf(mp, "", "World"); fputs(x, stdout); - x = mp_printf(mp, "Hello, %100s!\n", "World"); + x = mp_printf(mp, "\n", "World"); fputs(x, stdout); return 0; } diff --git a/lib/mempool-str.c b/lib/mempool-str.c index acee64a8..0da43e16 100644 --- a/lib/mempool-str.c +++ b/lib/mempool-str.c @@ -50,3 +50,18 @@ mp_multicat(struct mempool *p, ...) *y = 0; return buf; } + +#ifdef TEST + +#include + +int main(void) +{ + struct mempool *p = mp_new(64); + char *s = mp_strdup(p, "12345"); + char *c = mp_multicat(p, "<<", s, ">>", NULL); + puts(c); + return 0; +} + +#endif diff --git a/lib/mempool.t b/lib/mempool.t new file mode 100644 index 00000000..0a3ccc41 --- /dev/null +++ b/lib/mempool.t @@ -0,0 +1,7 @@ +# Tests for mempool modules + +Run: obj/lib/mempool-fmt-t +Out: + +Run: obj/lib/mempool-str-t +Out: <<12345>> -- 2.39.2