455b14d7cf410618caab337b1dbe978e95fd7de7
[platform/upstream/glibc.git] / stdio-common / bug1.c
1 #include <stdio.h>
2 #include <string.h>
3
4 int
5 main (void)
6 {
7   char *bp;
8   size_t size;
9   FILE *stream;
10   int lose = 0;
11
12   stream = open_memstream (&bp, &size);
13   fprintf (stream, "hello");
14   fflush (stream);
15   printf ("buf = %s, size = %d\n", bp, size);
16   lose |= size != 5;
17   lose |= strncmp (bp, "hello", size);
18   fprintf (stream, ", world");
19   fclose (stream);
20   printf ("buf = %s, size = %d\n", bp, size);
21   lose |= size != 12;
22   lose |= strncmp (bp, "hello, world", 12);
23
24   puts (lose ? "Test FAILED!" : "Test succeeded.");
25
26   return lose;
27 }