]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libtextstyle: Add test for ostream_printf.
authorBruno Haible <bruno@clisp.org>
Mon, 28 Oct 2019 00:11:21 +0000 (01:11 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 28 Oct 2019 00:11:21 +0000 (01:11 +0100)
* libtextstyle/gnulib-local/tests/test-memory-ostream.c: New file.
* libtextstyle/gnulib-local/modules/memory-ostream-tests: New file.
* libtextstyle/Makefile.am (EXTRA_DIST): Add them.
* libtextstyle/autogen.sh (GNULIB_MODULES): Add 'memory-ostream-tests'.

libtextstyle/Makefile.am
libtextstyle/autogen.sh
libtextstyle/gnulib-local/modules/memory-ostream-tests [new file with mode: 0644]
libtextstyle/gnulib-local/tests/test-memory-ostream.c [new file with mode: 0644]

index 0f4576cf1bc56d36caee6a25e4c6b974e33fd83b..318c0320fae7e3de4855233e2be89752356e0d91 100644 (file)
@@ -144,6 +144,7 @@ EXTRA_DIST = \
   gnulib-local/modules/libglib \
   gnulib-local/modules/libxml.diff \
   gnulib-local/modules/memory-ostream \
+  gnulib-local/modules/memory-ostream-tests \
   gnulib-local/modules/moo \
   gnulib-local/modules/moo-tests \
   gnulib-local/modules/noop-styled-ostream \
@@ -156,6 +157,7 @@ EXTRA_DIST = \
   gnulib-local/modules/term-ostream \
   gnulib-local/modules/term-ostream-tests \
   gnulib-local/modules/term-styled-ostream \
+  gnulib-local/tests/test-memory-ostream.c \
   gnulib-local/tests/test-moo-aroot.oo.c \
   gnulib-local/tests/test-moo-aroot.oo.h \
   gnulib-local/tests/test-moo-assign.c \
index 9edce49cade056cebec2347628a9ac254750f90a..160bae4d84ff1a6b2552662a76008a2e3cdf4738 100755 (executable)
@@ -91,6 +91,7 @@ if test $skip_gnulib = false; then
     xalloc
     xconcat-filename
 
+    memory-ostream-tests
     term-ostream-tests
   '
   $GNULIB_TOOL --lib=libtextstyle --source-base=lib --m4-base=gnulib-m4 --tests-base=tests \
diff --git a/libtextstyle/gnulib-local/modules/memory-ostream-tests b/libtextstyle/gnulib-local/modules/memory-ostream-tests
new file mode 100644 (file)
index 0000000..fb6ef84
--- /dev/null
@@ -0,0 +1,10 @@
+Files:
+tests/test-memory-ostream.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-memory-ostream
+check_PROGRAMS += test-memory-ostream
diff --git a/libtextstyle/gnulib-local/tests/test-memory-ostream.c b/libtextstyle/gnulib-local/tests/test-memory-ostream.c
new file mode 100644 (file)
index 0000000..bc6dfdc
--- /dev/null
@@ -0,0 +1,33 @@
+/* Test for the memory-ostream API.  */
+
+#include <config.h>
+
+#include "memory-ostream.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+  memory_ostream_t stream = memory_ostream_create ();
+
+  ostream_write_str (stream, "foo");
+  ostream_printf (stream, "%d%d", 73, 55);
+  ostream_write_str (stream, "\n");
+
+  {
+    const void *buf;
+    size_t buflen;
+    memory_ostream_contents (stream, &buf, &buflen);
+
+    if (!(buflen == 8))
+      exit (2);
+    if (!(memcmp (buf, "foo7355\n", 8) == 0))
+      exit (3);
+
+    ostream_free (stream);
+  }
+
+  return 0;
+}