Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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"
21#include "lib/format-cout.hpp"
22#include "lib/file.hpp"
23#include "lib/util.hpp"
24
25#include "lib/searchpath.hpp"
26
27
28using util::isnil;
29
30namespace lib {
31namespace test {
32
33
34 /**************************************************/
40 class SearchPathSplitter_test : public Test
41 {
42 void
43 run (Arg)
44 {
47 }
48
49
50 void
52 {
53 walk ("");
54 walk (":");
55 walk ("a:");
56 walk (":a");
57 walk ("a:b");
58 walk (":a:b\n:c:");
59 walk (" d : e f ");
60 walk ("/usr/bin:/usr/lib");
61
63 CHECK (not sp);
64 VERIFY_ERROR (ITER_EXHAUST, *sp );
65 }
66
67 void
68 walk (string spec)
69 {
70 SearchPathSplitter path{spec};
71 for (auto const& pathElm : path)
72 cout <<"▶"<< pathElm <<"◀"<< endl;
73 }
74
75
76
77 void
79 {
80 fs::path exePath{findExePath()};
81 string expected{exePath.parent_path() / "modules"};
82
83 string searchSpec = "xyz:$ORIGIN/modules:abc";
84 SearchPathSplitter sp{searchSpec};
85 CHECK (*sp == "xyz"_expect);
86 ++sp;
87 CHECK (*sp == ExpectString{expected});
88 ++sp;
89 CHECK (*sp == "abc"_expect);
90 ++sp;
91 CHECK (isnil (sp));
92 }
93 };
94
95
97
98
99}} // namespace lib::test
Helper: Access a path Specification as a sequence of filesystem Paths.
Helper to produce better diagnostic messages when comparing to an expected result string.
Includes the C++ Filesystem library and provides some convenience helpers.
Automatically use custom string conversion in C++ stream output.
Implementation namespace for support and library code.
fs::path findExePath()
retrieve the location of the executable
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Helpers to handle directory search paths.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...