9 # define OPEN_MEMSTREAM open_memstream
17 mcheck_abort (enum mcheck_status ev
)
19 printf ("mecheck failed with status %d\n", (int) ev
);
27 mcheck_pedantic (mcheck_abort
);
29 CHAR_T
*buf
= (CHAR_T
*) 1l;
31 FILE *fp
= OPEN_MEMSTREAM (&buf
, &len
);
34 printf ("%s failed\n", S(OPEN_MEMSTREAM
));
38 for (int outer
= 0; outer
< 800; ++outer
)
40 for (int inner
= 0; inner
< 100; ++inner
)
41 if (fputc (W('a') + (outer
* 100 + inner
) % 26, fp
) == EOF
)
43 printf ("fputc at %d:%d failed\n", outer
, inner
);
49 puts ("fflush failed");
53 if (len
!= (outer
+ 1) * 100)
55 printf ("string in round %d not %d bytest long\n",
56 outer
+ 1, (outer
+ 1) * 100);
59 if (buf
== (CHAR_T
*) 1l)
61 printf ("round %d: buf not updated\n", outer
+ 1);
64 for (int inner
= 0; inner
< (outer
+ 1) * 100; ++inner
)
65 if (buf
[inner
] != W('a') + inner
% 26)
67 printf ("round %d: buf[%d] != '%c'\n", outer
+ 1, inner
,
68 (char) (W('a') + inner
% 26));
77 puts ("fclose failed");
83 puts ("string after close not 80000 bytes long");
86 if (buf
== (CHAR_T
*) 1l)
88 puts ("buf not updated");
91 for (int inner
= 0; inner
< 800 * 100; ++inner
)
92 if (buf
[inner
] != W('a') + inner
% 26)
94 printf ("after close: buf[%d] != %c\n", inner
,
95 (char) (W('a') + inner
% 26));
105 #define TEST_FUNCTION do_test ()
106 #include "../test-skeleton.c"