0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 03:07:54 +01:00
nodejs/test/wasi/c/freopen.c
cjihrig 96058f33a9 test: add wasi test for freopen()
This test provides missing coverage for __wasi_fd_renumber().

PR-URL: https://github.com/nodejs/node/pull/31432
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-01-23 05:22:36 -08:00

17 lines
377 B
C

#include <assert.h>
#include <stdio.h>
int main() {
FILE* file_orig = fopen("/sandbox/input.txt", "r");
assert(file_orig != NULL);
FILE* file_new = freopen("/sandbox/input2.txt", "r", file_orig);
assert(file_new != NULL);
int c = fgetc(file_new);
while (c != EOF) {
int wrote = fputc((char)c, stdout);
assert(wrote != EOF);
c = fgetc(file_new);
}
}