Lumiera  0.pre.03
»edit your freedom«
search-path-splitter-test.cpp
Go to the documentation of this file.
1 /*
2  SearchPathSplitter(Test) - iterating a search path specification
3 
4  Copyright (C)
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
19 #include "lib/test/run.hpp"
20 #include "lib/test/test-helper.hpp"
21 #include "lib/format-cout.hpp"
22 
23 #include "lib/searchpath.hpp"
24 
25 
26 
27 
28 namespace lib {
29 namespace test {
30 
31 
32  /**************************************************/
38  class SearchPathSplitter_test : public Test
39  {
40  void
41  run (Arg)
42  {
43  walkSimplePaths ();
44  resolveEmbeddedOriginToken ();
45  }
46 
47 
48  void
49  walkSimplePaths ()
50  {
51  walk ("");
52  walk (":");
53  walk ("a:");
54  walk (":a");
55  walk ("a:b");
56  walk (":a:b:c:");
57  walk (" d : e f");
58  walk ("/usr/bin:/usr/lib");
59 
60  SearchPathSplitter sp("");
61  VERIFY_ERROR (ITER_EXHAUST, sp.next() );
62  }
63 
64  void
65  walk (string spec)
66  {
67  SearchPathSplitter path(spec);
68  while (path)
69  cout << "➢➢" << path.next() << endl;
70  }
71 
72 
73 
74  void
75  resolveEmbeddedOriginToken ()
76  {
77  fsys::path exePath (findExePath());
78  string expected = (exePath.remove_leaf() / "modules").string();
79 
80  SearchPathSplitter sp("xyz:$ORIGIN/modules:abc");
81  CHECK ("xyz" == sp.next());
82  CHECK (sp.next() == expected);
83  CHECK ("abc" == sp.next());
84  CHECK (!sp.isValid());
85  }
86  };
87 
88 
89  LAUNCHER (SearchPathSplitter_test, "unit common");
90 
91 
92 }} // namespace lib::test
Helpers to handle directory search paths.
Automatically use custom string conversion in C++ stream output.
string findExePath()
retrieve the location of the executable
Definition: searchpath.cpp:44
Definition: run.hpp:40
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Implementation namespace for support and library code.
Simplistic test class runner.
A collection of frequently used helper functions to support unit testing.
Helper: Access a path Specification as a sequence of filesystem Paths.
Definition: searchpath.hpp:62