1 /* Test for the memory-ostream API. */
2
3 #include <config.h>
4
5 #include "memory-ostream.h"
6
7 #include <stdlib.h>
8 #include <string.h>
9
10 int
11 main ()
12 {
13 memory_ostream_t stream = memory_ostream_create ();
14
15 ostream_write_str (stream, "foo");
16 ostream_printf (stream, "%d%d", 73, 55);
17 ostream_write_str (stream, "\n");
18
19 {
20 const void *buf;
21 size_t buflen;
22 memory_ostream_contents (stream, &buf, &buflen);
23
24 if (!(buflen == 8))
25 exit (2);
26 if (!(memcmp (buf, "foo7355\n", 8) == 0))
27 exit (3);
28
29 ostream_free (stream);
30 }
31
32 return 0;
33 }