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