split_path_test.cc
Go to the documentation of this file.
1 #include "cetlib/split_path.h"
2 #include <cassert>
3 
4 using cet::split_path;
5 using std::string;
6 using std::vector;
7 
8 void
10 {
11  vector<string> results;
12  split_path("", results);
13  assert(results.empty());
14 }
15 
16 void
18 {
19  vector<string> results;
20  string sole_entry("ABC_D/EFG/H");
21  split_path(sole_entry, results);
22  assert(results.size() == 1);
23  assert(results[0] == sole_entry);
24 }
25 
26 void
28 {
29  vector<string> results;
30  string path("A::B");
31  split_path(path, results);
32  assert(results.size() == 3);
33  assert(results[0] == "A");
34  assert(results[1] == "");
35  assert(results[2] == "B");
36 }
37 
38 void
40 {
41  vector<string> results;
42  string path(":BOO");
43  split_path(path, results);
44  assert(results.size() == 2);
45  assert(results[0].empty());
46  assert(results[1] == "BOO");
47 }
48 
49 void
51 {
52  vector<string> results;
53  string path("A:");
54  split_path(path, results);
55  assert(results.size() == 2);
56  assert(results[0] == "A");
57  assert(results[1].empty());
58 }
59 
60 void
62 {
63  vector<string> results;
64  vector<string> path_elements;
65  path_elements.push_back("/p/gcc/v4_5_1/Linux64/lib64");
66  path_elements.push_back("/p/gcc/v4_5_1/Linux64/lib");
67  path_elements.push_back("/p/root/v5_26_00d/lib");
68  path_elements.push_back("/p/cmake/v2_6_4/.");
69  path_elements.push_back("/p/cppunit/v1_12_1/slf5.x86_64.a1/lib");
70  string path = path_elements[0];
71  for (size_t i = 1; i < path_elements.size(); ++i) {
72  path += ":";
73  path += path_elements[i];
74  }
75 
76  // Now do the test
77  split_path(path, results);
78  assert(results == path_elements);
79 }
80 
81 int
83 {
90 }
std::string string
Definition: nybbler.cc:12
struct vector vector
void test_leading_colon()
int main()
void test_empty_path()
void split_path(std::string const &path, std::vector< std::string > &components)
Definition: split_path.cc:13
void test_typical_use()
void test_trailing_colon()
void test_single_entry_path()
void test_adjacent_colons()
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97