• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <boost/test/included/unit_test.hpp>
12 #include <boost/process/search_path.hpp>
13 #include <boost/filesystem/path.hpp>
14 #include <string>
15 
16 namespace bp = boost::process;
17 namespace fs = boost::filesystem;
18 
BOOST_AUTO_TEST_CASE(search_path)19 BOOST_AUTO_TEST_CASE(search_path)
20 {
21 #if defined(BOOST_WINDOWS_API)
22     std::string filename = "cmd";
23 #elif defined(BOOST_POSIX_API)
24     fs::path filename = "ls";
25 #endif
26 
27     BOOST_CHECK(!bp::search_path(filename).empty());
28     auto fs = bp::search_path(filename);
29 
30     std::cout << fs << std::endl;
31 
32 #if defined(BOOST_WINDOWS_API)
33     std::vector<fs::path> path = {"C:\\Windows","C:\\Windows\\System32"};
34 #elif defined(BOOST_POSIX_API)
35     std::vector<fs::path> path = {"/usr/local/bin","/usr/bin","/bin"};
36 #endif
37 
38     BOOST_CHECK(!bp::search_path(filename, path).empty());
39 }
40