浏览代码

Unit test arbitrarily long ungetc()

oddcoder 4 年之前
父节点
当前提交
49dec86a5d

+ 1 - 0
tests/Makefile

@@ -42,6 +42,7 @@ EXPECT_NAMES=\
 	stdio/setvbuf \
 	stdio/sprintf \
 	stdio/printf_space_pad \
+	stdio/ungetc_multiple \
 	stdlib/a64l \
 	stdlib/alloc \
 	stdlib/atof \

+ 0 - 0
tests/expected/stdio/ungetc_multiple.stderr


+ 1 - 0
tests/expected/stdio/ungetc_multiple.stdout

@@ -0,0 +1 @@
+hello world

+ 27 - 0
tests/stdio/ungetc_multiple.c

@@ -0,0 +1,27 @@
+#include <stdio.h>
+int main() {
+  ungetc('\n', stdin);
+  ungetc('d', stdin);
+  ungetc('l', stdin);
+  ungetc('r', stdin);
+  ungetc('o', stdin);
+  ungetc('w', stdin);
+  ungetc(' ', stdin);
+  ungetc('o', stdin);
+  ungetc('l', stdin);
+  ungetc('l', stdin);
+  ungetc('e', stdin);
+  ungetc('h', stdin);
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+  putchar(getchar());
+}