]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | ||
4 | int | |
ebbad4cc | 5 | main (void) |
28f540f4 RM |
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 | } |