]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // Copyright (c) 2006, 2007 Julio M. Merino Vidal |
2 | // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling | |
3 | // Copyright (c) 2009 Boris Schaeling | |
4 | // Copyright (c) 2010 Felipe Tanus, Boris Schaeling | |
5 | // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling | |
6 | // | |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | #define BOOST_TEST_MAIN | |
11 | #define BOOST_TEST_IGNORE_SIGCHLD | |
12 | ||
13 | #include <boost/test/included/unit_test.hpp> | |
14 | ||
15 | #include <boost/process/exe.hpp> | |
16 | #include <boost/process/args.hpp> | |
17 | #include <boost/process/cmd.hpp> | |
18 | #include <boost/process/io.hpp> | |
19 | #include <boost/process/error.hpp> | |
20 | #include <boost/process/child.hpp> | |
21 | ||
22 | #include <boost/algorithm/string/predicate.hpp> | |
23 | ||
24 | namespace bp = boost::process; | |
25 | ||
26 | ||
92f5a8d4 | 27 | BOOST_AUTO_TEST_CASE(wargs, *boost::unit_test::timeout(2)) |
b32b8144 FG |
28 | { |
29 | using boost::unit_test::framework::master_test_suite; | |
30 | ||
31 | bp::ipstream is; | |
32 | ||
33 | std::error_code ec; | |
34 | bp::child c( | |
35 | master_test_suite().argv[1], | |
36 | L"test", "--echo-argv", L"hello thingy", "\"stuff\"", static_cast<const wchar_t*>(L" spa ce "), | |
37 | bp::std_out>is, | |
38 | ec | |
39 | ); | |
40 | if (ec) | |
41 | std::cout << "EC: " << ec.message() << std::endl; | |
42 | BOOST_REQUIRE(!ec); | |
43 | ||
44 | std::string s; | |
45 | ||
46 | std::getline(is, s); | |
47 | s.resize(4); | |
48 | BOOST_CHECK_EQUAL(s, "test"); | |
49 | ||
50 | std::getline(is, s); | |
51 | s.resize(11); | |
52 | BOOST_CHECK_EQUAL(s, "--echo-argv"); | |
53 | ||
54 | std::getline(is, s); | |
55 | s.resize(12); | |
56 | ||
57 | BOOST_CHECK_EQUAL(s, "hello thingy"); | |
58 | ||
59 | std::getline(is, s); | |
60 | s.resize(7); | |
61 | ||
62 | BOOST_CHECK_EQUAL(s, "\"stuff\""); | |
63 | ||
64 | std::getline(is, s); | |
65 | s.resize(10); | |
66 | ||
67 | BOOST_CHECK_EQUAL(s, " spa ce "); | |
68 | ||
69 | } | |
70 | ||
71 | ||
92f5a8d4 | 72 | BOOST_AUTO_TEST_CASE(wcmd, *boost::unit_test::timeout(2)) |
b32b8144 FG |
73 | { |
74 | using boost::unit_test::framework::master_test_suite; | |
75 | ||
76 | bp::ipstream is; | |
77 | ||
78 | std::error_code ec; | |
79 | ||
80 | std::wstring cmd = | |
81 | bp::detail::convert(master_test_suite().argv[1]); | |
82 | cmd+= L" test --echo-argv \"hello thingy\" \\\"stuff\\\" \" spa ce \""; | |
83 | ||
84 | bp::child c(cmd, | |
85 | bp::std_out>is, | |
86 | ec | |
87 | ); | |
88 | BOOST_REQUIRE(!ec); | |
89 | ||
90 | std::string s; | |
91 | ||
92 | std::getline(is, s); | |
93 | s.resize(4); | |
94 | BOOST_CHECK_EQUAL(s, "test"); | |
95 | ||
96 | std::getline(is, s); | |
97 | s.resize(11); | |
98 | BOOST_CHECK_EQUAL(s, "--echo-argv"); | |
99 | ||
100 | std::getline(is, s); | |
101 | s.resize(12); | |
102 | ||
103 | BOOST_CHECK_EQUAL(s, "hello thingy"); | |
104 | ||
105 | std::getline(is, s); | |
106 | s.resize(7); | |
107 | ||
108 | BOOST_CHECK_EQUAL(s, "\"stuff\""); | |
109 | ||
110 | std::getline(is, s); | |
111 | s.resize(10); | |
112 | ||
113 | BOOST_CHECK_EQUAL(s, " spa ce "); | |
114 | } | |
115 |