8 # define OPEN_MEMSTREAM open_memstream
16 mcheck_abort (enum mcheck_status ev
)
18 printf ("mecheck failed with status %d\n", (int) ev
);
26 mcheck_pedantic (mcheck_abort
);
28 CHAR_T
*buf
= (CHAR_T
*) 1l;
30 FILE *fp
= OPEN_MEMSTREAM (&buf
, &len
);
33 printf ("%s failed\n", S(OPEN_MEMSTREAM
));
37 for (int outer
= 0; outer
< 800; ++outer
)
39 for (int inner
= 0; inner
< 100; ++inner
)
40 if (fputc (W('a') + (outer
* 100 + inner
) % 26, fp
) == EOF
)
42 printf ("fputc at %d:%d failed\n", outer
, inner
);
48 puts ("fflush failed");
52 if (len
!= (outer
+ 1) * 100)
54 printf ("string in round %d not %d bytest long\n",
55 outer
+ 1, (outer
+ 1) * 100);
58 if (buf
== (CHAR_T
*) 1l)
60 printf ("round %d: buf not updated\n", outer
+ 1);
63 for (int inner
= 0; inner
< (outer
+ 1) * 100; ++inner
)
64 if (buf
[inner
] != W('a') + inner
% 26)
66 printf ("round %d: buf[%d] != '%c'\n", outer
+ 1, inner
,
67 (char) (W('a') + inner
% 26));
76 puts ("fclose failed");
82 puts ("string after close not 80000 bytes long");
85 if (buf
== (CHAR_T
*) 1l)
87 puts ("buf not updated");
90 for (int inner
= 0; inner
< 800 * 100; ++inner
)
91 if (buf
[inner
] != W('a') + inner
% 26)
93 printf ("after close: buf[%d] != %c\n", inner
,
94 (char) (W('a') + inner
% 26));
103 #define TEST_FUNCTION do_test ()
104 #include "../test-skeleton.c"