is_absolute_filepath_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (is_absolute_filepath_t test)
2 #include "boost/test/unit_test.hpp"
3 
4 #include <string>
5 
6 #include "cetlib/filesystem.h"
7 
8 BOOST_AUTO_TEST_SUITE(is_absolute_filepath_t)
9 
10 BOOST_AUTO_TEST_CASE(accept_absolute_filenames)
11 {
12  std::string const absolute1("/a/b/c.txt");
13  BOOST_TEST(cet::is_absolute_filepath(absolute1));
14  BOOST_TEST(cet::is_absolute_filepath("/a/b/ccc"));
15  BOOST_TEST(cet::is_absolute_filepath("/"));
16 
17  BOOST_TEST(!cet::is_relative_filepath(absolute1));
18  BOOST_TEST(!cet::is_relative_filepath("/a/b/ccc"));
19  BOOST_TEST(!cet::is_relative_filepath("/"));
20 }
21 
22 BOOST_AUTO_TEST_CASE(reject_relative_filenames)
23 {
24  std::string const relative("a/b/c.txt");
25  BOOST_TEST(!cet::is_absolute_filepath(relative));
26  BOOST_TEST(!cet::is_absolute_filepath(""));
27  BOOST_TEST(!cet::is_absolute_filepath("."));
28  BOOST_TEST(!cet::is_absolute_filepath("../"));
29 
30  BOOST_TEST(cet::is_relative_filepath(relative));
31  BOOST_TEST(cet::is_relative_filepath(""));
32  BOOST_TEST(cet::is_relative_filepath("."));
33  BOOST_TEST(cet::is_relative_filepath("../"));
34 }
35 
36 BOOST_AUTO_TEST_SUITE_END()
std::string string
Definition: nybbler.cc:12
bool is_relative_filepath(std::string const &qualified_filename)
Definition: filesystem.cc:29
BOOST_AUTO_TEST_CASE(accept_absolute_filenames)
bool is_absolute_filepath(std::string const &qualified_filename)
Definition: filesystem.cc:23