diff --git a/test/test_subprocess.cc b/test/test_subprocess.cc new file mode 100755 index 0000000..dcffb27 --- /dev/null +++ b/test/test_subprocess.cc @@ -0,0 +1,20 @@ +#include +#include "../subprocess.hpp" + +using namespace subprocess; + +void test_input() +{ + auto p = Popen({"grep", "f"}, output{PIPE}, input{PIPE}); + const char* msg = "one\ntwo\nfour\n"; + std::fwrite(msg, 1, strlen(msg), p.input()); + fclose (p.input()); + + std::vector rbuf(128); + std::fread(rbuf.data(), 1, 128, p.output()); +} + +int main() { + test_input(); + return 0; +}