Test CLI program

Hello,
I have a program (chess engine) which waits for user inputs to make any process. These inputs are gathered from the reader of std.io.getStdIn(). Is there a way to simulate such commands in tests ?
Maybe there is a way to put data into the GenericReader type ?

If you’re accepting a reader as an anytype, this would work:

// whatever input you expect from stdin
const input = "e4 e5\nNf3 Nc6\n";
var fbs = std.io.fixedBufferStream(input);
const reader = fbs.reader();

yourReadFunction(reader);
8 Likes

Thanks! fixedBufferStream() was the element I missed

2 Likes