MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / processChainInheritDual

Method processChainInheritDual

Tests/Libraries/Process/ProcessTest.cpp:200–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void SC::ProcessTest::processChainInheritDual()
201{
202 //! [processChainInheritDualSnippet]
203 // Executes two processes piping output of process p1 to input of process p2.
204 // Then reads the output of the last process in the chain and check its correctness.
205 ProcessChain chain;
206 Process p1, p2;
207 // Print "Salve\nDoctori" on Windows and Posix and then grep for "Doc"
208 StringView expectedOutput;
209 switch (HostPlatform)
210 {
211 case Platform::Windows: {
212 expectedOutput = "Doctori\r\n";
213 SC_TEST_EXPECT(chain.pipe(p1, {"cmd", "/C", "echo", "Salve", "&", "echo", "Doctori"}));
214 SC_TEST_EXPECT(chain.pipe(p2, {"findstr", "Doc"}));
215 }
216 break;
217 default: { // Posix
218 expectedOutput = "Doctori\n";
219 SC_TEST_EXPECT(chain.pipe(p1, {"echo", "Salve\nDoctori"}));
220 SC_TEST_EXPECT(chain.pipe(p2, {"grep", "Doc"}));
221 }
222 break;
223 }
224 String output;
225 SC_TEST_EXPECT(chain.exec(output));
226 SC_TEST_EXPECT(output == expectedOutput);
227 //! [processChainInheritDualSnippet]
228}
229
230void SC::ProcessTest::processChainPipeSingle()
231{

Callers

nothing calls this directly

Calls 1

pipeMethod · 0.45

Tested by

no test coverage detected