MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / test_exception

Function test_exception

test/test_exception.cc:7–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace sp = subprocess;
6
7void test_exception()
8{
9 bool caught = false;
10 try {
11 auto p = sp::Popen("invalid_command");
12 assert(false); // Expected to throw
13 } catch (sp::CalledProcessError& e) {
14#ifdef __USING_WINDOWS__
15 assert(std::strstr(e.what(), "CreateProcess failed: The system cannot find the file specified."));
16#else
17 assert(std::strstr(e.what(), "execve failed: No such file or directory"));
18#endif
19 caught = true;
20 }
21 assert(caught);
22}
23
24int main() {
25 test_exception();

Callers 1

mainFunction · 0.85

Calls 1

PopenClass · 0.85

Tested by

no test coverage detected