1 #ifndef _POSIX_C_SOURCE 3 #define _POSIX_C_SOURCE 200112L 6 #include "catch2/catch.hpp" 26 string const test_path{
"/dev/null/nopath:/dev/null/xpath"};
31 return (path.empty() ? 0ull :
32 std::count(path.cbegin(), path.cend(),
':') + 1ull);
35 std::size_t
const tp_sz = path_entries(test_path);
38 remove_dups_from_path(
string const& path)
41 std::vector<string> path_bits;
42 std::set<string> paths_used;
44 for (
auto const& bit : path_bits) {
45 if (paths_used.find(bit) == paths_used.end()) {
46 if (!result.empty()) {
50 paths_used.insert(bit);
62 if (default_libpath.empty()) {
77 ":" + libpath_before)};
79 CHECK(tp_sz == sp.size());
82 CHECK(tp_sz < path_entries(libpath));
86 SECTION(
"Standard Null")
91 CHECK(path_entries(libpath) == sp.size());
92 CHECK(remove_dups_from_path(libpath_before) == libpath);
96 SECTION(
"Standard Empty")
100 CHECK(1ull == sp.size());
107 setenv(
"SIMPLE_VAR", test_path.c_str(), 1);
110 CHECK(tp_sz == sp.size());
112 CHECK(remove_dups_from_path(
expected) == libpath);
113 CHECK(tp_sz < path_entries(libpath));
117 SECTION(
"Custom Null")
120 CHECK(1ull == sp.size());
125 SECTION(
"Custom Empty")
127 setenv(
"EMPTY_VAR",
"", 1);
129 CHECK(1ull == sp.size());
134 setenv(
os_libpath(), default_libpath.c_str(), 1);
constexpr char const * os_libpath()
constexpr char const * plugin_libpath()
std::string getenv(std::string const &name)
search_path plugin_search_path()
void split_path(std::string const &path, std::vector< std::string > &components)