Warning: That file was not part of the compilation database. It may have many parsing errors.

1#include <mcheck.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5
6#ifndef CHAR_T
7# define CHAR_T char
8# define W(o) o
9# define OPEN_MEMSTREAM open_memstream
10#endif
11
12#define S(s) S1 (s)
13#define S1(s) #s
14
15
16static void
17mcheck_abort (enum mcheck_status ev)
18{
19 printf ("mecheck failed with status %d\n", (int) ev);
20 exit (1);
21}
22
23
24static int
25do_test (void)
26{
27 mcheck_pedantic (mcheck_abort);
28
29 CHAR_T *buf = (CHAR_T *) 1l;
30 size_t len = 12345;
31 FILE *fp = OPEN_MEMSTREAM (&buf, &len);
32 if (fp == NULL)
33 {
34 printf ("%s failed\n", S(OPEN_MEMSTREAM));
35 return 1;
36 }
37
38 if (fflush (fp) != 0)
39 {
40 puts ("fflush failed");
41 return 1;
42 }
43
44 if (len != 0)
45 {
46 puts ("string after no write not empty");
47 return 1;
48 }
49 if (buf == (CHAR_T *) 1l)
50 {
51 puts ("buf not updated");
52 return 1;
53 }
54 if (buf[0] != W('\0'))
55 {
56 puts ("buf[0] != 0");
57 return 1;
58 }
59
60 buf = (CHAR_T *) 1l;
61 len = 12345;
62 if (fclose (fp) != 0)
63 {
64 puts ("fclose failed");
65 return 1;
66 }
67
68 if (len != 0)
69 {
70 puts ("string after close with no write not empty");
71 return 1;
72 }
73 if (buf == (CHAR_T *) 1l)
74 {
75 puts ("buf not updated");
76 return 1;
77 }
78 if (buf[0] != W('\0'))
79 {
80 puts ("buf[0] != 0");
81 return 1;
82 }
83
84 free (buf);
85
86 return 0;
87}
88
89#define TEST_FUNCTION do_test ()
90#include "../test-skeleton.c"
91

Warning: That file was not part of the compilation database. It may have many parsing errors.