1 /* Test for ungetc bugs. */
9 fputs ("test failed: " #x "\n", stderr); \
15 main (int argc
, char *argv
[])
24 fp
= fopen (name
, "w");
30 fp
= fopen (name
, "r");
32 assert (ungetc ('z', fp
) == 'z');
33 assert (getc (fp
) == 'z');
34 assert (getc (fp
) == 'b');
35 assert (getc (fp
) == 'l');
36 assert (ungetc ('m', fp
) == 'm');
37 assert (getc (fp
) == 'm');
38 assert ((c
= getc (fp
)) == 'a');
39 assert (getc (fp
) == EOF
);
40 assert (ungetc (c
, fp
) == c
);
41 assert (feof (fp
) == 0);
42 assert (getc (fp
) == c
);
43 assert (getc (fp
) == EOF
);
47 fp
= fopen (name
, "r");
49 assert (getc (fp
) == 'b');
50 assert (getc (fp
) == 'l');
51 assert (ungetc ('b', fp
) == 'b');
52 assert (fread (buffer
, 1, 64, fp
) == 2);
53 assert (buffer
[0] == 'b');
54 assert (buffer
[1] == 'a');