Update.
[glibc.git] / stdio-common / bug1.c
blob51639d3476c5d4f24413fa9681fe6db639a52d35
1 #include <stdio.h>
2 #include <string.h>
4 int
5 main (void)
7 char *bp;
8 size_t size;
9 FILE *stream;
10 int lose = 0;
12 stream = open_memstream (&bp, &size);
13 fprintf (stream, "hello");
14 fflush (stream);
15 printf ("buf = %s, size = %Zu\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 = %Zu\n", bp, size);
21 lose |= size != 12;
22 lose |= strncmp (bp, "hello, world", 12);
24 puts (lose ? "Test FAILED!" : "Test succeeded.");
26 return lose;