7 #define BOOST_TEST_MODULE (filepath_maker test) 8 #include "boost/test/unit_test.hpp" 10 #include "boost/filesystem.hpp" 14 #include "cetlib_except/exception.h" 18 namespace bfs = boost::filesystem;
22 std::string const path{
"FILEPATH_MAKER_TEST_FILES"};
23 std::string const file_in_current_dir{
"filepath_maker_test.txt"};
34 return current_dir() +
"/filepath_maker-files";
40 BOOST_CHECK_EXCEPTION(
42 return e.category() ==
"search_path";
47 BOOST_AUTO_TEST_SUITE(filepath_maker_test)
53 auto const files = {
"a.txt",
"./b.txt",
"/c/d.txt"};
63 auto const files = {
"a.txt"s,
"b.txt"s,
"c.txt"s};
70 bfs::path
const p1{fullPath1};
71 bfs::path
const p2{fullPath2};
72 bfs::path
const p3{fullPath3};
73 BOOST_TEST(bfs::equivalent(p1, p2));
74 BOOST_TEST(bfs::equivalent(p1, p3));
80 check_exception(
maker, current_nested_dir() +
'/' +
filename);
89 check_exception(
maker, file_in_current_dir);
95 auto const files = {
"a.txt"s,
"b.txt"s,
"c.txt"s};
99 auto const fullPath2 =
maker(current_nested_dir() +
'/' +
filename);
100 bfs::path
const p1{fullPath1};
101 bfs::path
const p2{fullPath2};
102 BOOST_TEST(bfs::equivalent(p1, p2));
110 check_exception(
maker, file_in_current_dir);
112 maker(current_dir() +
'/' + file_in_current_dir);
127 auto const absolute_path = current_dir() +
'/' + file_in_current_dir;
129 maker(absolute_path);
131 check_exception(
maker, absolute_path);
136 check_exception(
maker, current_nested_dir() +
"/a.txt");
142 auto const relative_path =
"./" + file_in_current_dir;
144 maker(relative_path);
146 check_exception(
maker, relative_path);
151 check_exception(
maker, current_nested_dir() +
"/a.txt");
158 maker(file_in_current_dir);
160 check_exception(
maker, file_in_current_dir);
165 check_exception(
maker, current_nested_dir() +
"/a.txt");
181 auto const absolute_path = current_dir() +
'/' + file_in_current_dir;
183 maker(absolute_path);
185 check_exception(
maker, absolute_path);
190 check_exception(
maker, current_nested_dir() +
"/a.txt");
196 auto const relative_path =
"./" + file_in_current_dir;
198 maker(relative_path);
200 check_exception(
maker, relative_path);
205 check_exception(
maker, current_nested_dir() +
"/a.txt");
212 maker(file_in_current_dir);
214 check_exception(
maker, file_in_current_dir);
219 check_exception(
maker, current_nested_dir() +
"/a.txt");
222 BOOST_AUTO_TEST_SUITE_END()
std::string getenv(std::string const &name)
BOOST_AUTO_TEST_CASE(filepath_maker_t)
bool is_absolute_filepath(std::string const &qualified_filename)
bool file_exists(std::string const &qualified_filename)
def maker(G, ac, typename)
cet::coded_exception< error, detail::translate > exception