Functions
search_path_test.cc File Reference
#include <catch2/catch.hpp>
#include "cetlib/search_path.h"
#include "cetlib_except/exception.h"
#include "cetlib_except/exception_category_matcher.h"
#include <string>

Go to the source code of this file.

Functions

 TEST_CASE ("Autodetect env")
 
 TEST_CASE ("Autodetect missing env")
 
 TEST_CASE ("Autodetect path")
 
 TEST_CASE ("Missing env OK")
 
 TEST_CASE ("Specified path")
 
 TEST_CASE ("Path entry count checks")
 
 TEST_CASE ("Null find check")
 
 TEST_CASE ("Path reproduction check")
 

Function Documentation

TEST_CASE ( "Autodetect env"  )

Definition at line 13 of file search_path_test.cc.

14 {
15  auto const path = "xyzzy"s;
16  search_path const xyzzy{path};
17  CHECK(xyzzy.size() == 1);
18  CHECK(xyzzy.showenv() == path);
19 }
static QCString * s
Definition: config.cpp:1042
TEST_CASE ( "Autodetect missing env"  )

Definition at line 21 of file search_path_test.cc.

22 {
23  auto const path = "/MISSING/"s;
24  CHECK_THROWS_MATCHES(search_path{path},
26  cet::exception_category_matcher("getenv"));
27 }
static QCString * s
Definition: config.cpp:1042
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
TEST_CASE ( "Autodetect path"  )

Definition at line 29 of file search_path_test.cc.

30 {
31  search_path const xyzzy{":xyzzy"};
32  CHECK(xyzzy.size() == 1);
33  CHECK(xyzzy.showenv().empty());
34 }
TEST_CASE ( "Missing env OK"  )

Definition at line 36 of file search_path_test.cc.

37 {
38  auto const path{"/MISSING/"s};
39  search_path const sp{path, std::nothrow};
40  CHECK(sp.size() == 1);
41  CHECK(sp.showenv() == path);
42 }
static QCString * s
Definition: config.cpp:1042
TEST_CASE ( "Specified path"  )

Definition at line 44 of file search_path_test.cc.

45 {
46  search_path const sp{"/onedir", cet::path_tag};
47  CHECK(sp.size() == 1);
48  CHECK(sp.showenv().empty());
49 }
path_tag_t const path_tag
Definition: search_path.cc:60
TEST_CASE ( "Path entry count checks"  )

Definition at line 51 of file search_path_test.cc.

52 {
53  CHECK(search_path{":xyzzy:"}.size() == 1);
54  CHECK(search_path{"xyzzy:plugh"}.size() == 2);
55  CHECK(search_path{"xyzzy:::plugh"}.size() == 2);
56  CHECK(search_path{"xyzzy:plugh:twisty:grue"}.size() == 4);
57 
58  CHECK(!search_path{""}.empty());
59  CHECK(!search_path{":"}.empty());
60  CHECK(!search_path{"::"}.empty());
61 
62  CHECK(search_path{""}.size() == 1);
63  CHECK(search_path{":"}.size() == 1);
64  CHECK(search_path{"::"}.size() == 1);
65 }
std::size_t size() const
Definition: search_path.cc:82
bool empty() const
Definition: search_path.cc:76
TEST_CASE ( "Null find check"  )

Definition at line 67 of file search_path_test.cc.

68 {
69  search_path const sp{":/tmp:"};
70  CHECK_THROWS_MATCHES(sp.find_file(""),
72  cet::exception_category_matcher("search_path"));
73 }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
TEST_CASE ( "Path reproduction check"  )

Definition at line 75 of file search_path_test.cc.

76 {
77  CHECK(search_path{"a:bb:c.c"}.to_string() == "a:bb:c.c"s);
78 }
std::string to_string() const
Definition: search_path.cc:161
static QCString * s
Definition: config.cpp:1042