]> mj.ucw.cz Git - libucw.git/commitdiff
Added tests for the mempool string functions.
authorMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2005 22:00:31 +0000 (22:00 +0000)
committerMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2005 22:00:31 +0000 (22:00 +0000)
lib/Makefile
lib/mempool-fmt.c
lib/mempool-str.c
lib/mempool.t [new file with mode: 0644]

index c2d3e4858a2a5a10b035b5dfb2c24abf138e6251..deb40b0bcd813f0adad65803b3f4f5fafea1d5e1 100644 (file)
@@ -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
index 47bb71eb4a61c67eb8be7495a93b1fe3f578ef54..c8b1e4c823ecb9d04f81a6adf391e4e0d102a894 100644 (file)
@@ -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, "<Hello, %s!>", "World");
   fputs(x, stdout);
-  x = mp_printf(mp, "Hello, %100s!\n", "World");
+  x = mp_printf(mp, "<Hello, %50s!>\n", "World");
   fputs(x, stdout);
   return 0;
 }
index acee64a87452deae47952d9ce7a56b601ac6460f..0da43e16c2fa16c9ab078b2337f7c8769b0b73a8 100644 (file)
@@ -50,3 +50,18 @@ mp_multicat(struct mempool *p, ...)
   *y = 0;
   return buf;
 }
+
+#ifdef TEST
+
+#include <stdio.h>
+
+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 (file)
index 0000000..0a3ccc4
--- /dev/null
@@ -0,0 +1,7 @@
+# Tests for mempool modules
+
+Run:   obj/lib/mempool-fmt-t
+Out:   <Hello, World!><Hello,                                              World!>
+
+Run:   obj/lib/mempool-str-t
+Out:   <<12345>>