File tests/Commands.cpp changed (mode: 100644) (index aef7576..6ffb59d) |
... |
... |
TEST_CASE("Commands must have unique names", "[commands]") |
46 |
46 |
REQUIRE(cmd != nullptr); |
REQUIRE(cmd != nullptr); |
47 |
47 |
|
|
48 |
48 |
auto fakeCmd = make_unique<Cmd>("log", std::string(), std::string()); |
auto fakeCmd = make_unique<Cmd>("log", std::string(), std::string()); |
49 |
|
REQUIRE_THROWS_AS(Commands::add(std::move(fakeCmd)), std::runtime_error); |
|
|
49 |
|
REQUIRE_THROWS_AS(Commands::add(std::move(fakeCmd)), |
|
50 |
|
const std::runtime_error &); |
50 |
51 |
} |
} |
File tests/Config.cpp changed (mode: 100644) (index aa77618..d874cac) |
... |
... |
TEST_CASE("Loading file of wrong format throws exception", "[config]") |
92 |
92 |
Config child("tests/main.cpp"); |
Config child("tests/main.cpp"); |
93 |
93 |
|
|
94 |
94 |
namespace pt = boost::property_tree; |
namespace pt = boost::property_tree; |
95 |
|
REQUIRE_THROWS_AS(child.get("key", "v") == "value", pt::info_parser_error); |
|
|
95 |
|
REQUIRE_THROWS_AS(child.get("key", "v") == "value", |
|
96 |
|
const pt::info_parser_error &); |
96 |
97 |
} |
} |
File tests/Dit.cpp changed (mode: 100644) (index 5e6cafb..0f6303c) |
35 |
35 |
|
|
36 |
36 |
TEST_CASE("Dit throws exception on empty args", "[app][invocation]") |
TEST_CASE("Dit throws exception on empty args", "[app][invocation]") |
37 |
37 |
{ |
{ |
38 |
|
REQUIRE_THROWS_AS(Dit({}), std::runtime_error); |
|
|
38 |
|
REQUIRE_THROWS_AS(Dit({}), const std::runtime_error &); |
39 |
39 |
} |
} |
40 |
40 |
|
|
41 |
41 |
TEST_CASE("Dit throws exception on absent $HOME", "[app][invocation]") |
TEST_CASE("Dit throws exception on absent $HOME", "[app][invocation]") |
|
... |
... |
TEST_CASE("Dit throws exception on absent $HOME", "[app][invocation]") |
43 |
43 |
std::string home = std::getenv("HOME"); |
std::string home = std::getenv("HOME"); |
44 |
44 |
|
|
45 |
45 |
unsetenv("HOME"); |
unsetenv("HOME"); |
46 |
|
REQUIRE_THROWS_AS(Dit({ "dit" }), std::runtime_error); |
|
|
46 |
|
REQUIRE_THROWS_AS(Dit({ "dit" }), const std::runtime_error &); |
47 |
47 |
|
|
48 |
48 |
static std::string homeSet = "HOME=" + home; |
static std::string homeSet = "HOME=" + home; |
49 |
49 |
putenv(&homeSet[0]); |
putenv(&homeSet[0]); |
File tests/Invocation.cpp changed (mode: 100644) (index d12f481..c7e4a13) |
... |
... |
TEST_CASE("Wrong options.", "[invocation][completion]") |
331 |
331 |
|
|
332 |
332 |
SECTION("Error on running") |
SECTION("Error on running") |
333 |
333 |
{ |
{ |
334 |
|
REQUIRE_THROWS_AS(invocation.parse(), boost::program_options::error); |
|
|
334 |
|
REQUIRE_THROWS_AS(invocation.parse(), |
|
335 |
|
const boost::program_options::error &); |
335 |
336 |
} |
} |
336 |
337 |
} |
} |
337 |
338 |
|
|
|
... |
... |
TEST_CASE("Invocation throws if alias resolved isn't set.", "[invocation]") |
340 |
341 |
Invocation invocation; |
Invocation invocation; |
341 |
342 |
invocation.setCmdLine({ "alias" }); |
invocation.setCmdLine({ "alias" }); |
342 |
343 |
|
|
343 |
|
REQUIRE_THROWS_AS(invocation.parse(), std::bad_function_call); |
|
|
344 |
|
REQUIRE_THROWS_AS(invocation.parse(), const std::bad_function_call &); |
344 |
345 |
} |
} |
345 |
346 |
|
|
346 |
347 |
TEST_CASE("Aliases are decomposed.", "[invocation][alias][composition]") |
TEST_CASE("Aliases are decomposed.", "[invocation][alias][composition]") |
File tests/Item.cpp changed (mode: 100644) (index c21a2e9..fbca007) |
... |
... |
TEST_CASE("Wrongly named keys cause error.", "[item]") |
105 |
105 |
|
|
106 |
106 |
SECTION("On get().") |
SECTION("On get().") |
107 |
107 |
{ |
{ |
108 |
|
REQUIRE_THROWS_AS(item.getValue("!@@#$%^"), std::runtime_error); |
|
|
108 |
|
REQUIRE_THROWS_AS(item.getValue("!@@#$%^"), const std::runtime_error &); |
109 |
109 |
} |
} |
110 |
110 |
|
|
111 |
111 |
SECTION("On set().") |
SECTION("On set().") |
112 |
112 |
{ |
{ |
113 |
|
REQUIRE_THROWS_AS(item.setValue("!@@#$%^", "b"), std::runtime_error); |
|
|
113 |
|
REQUIRE_THROWS_AS(item.setValue("!@@#$%^", "b"), |
|
114 |
|
const std::runtime_error &); |
114 |
115 |
} |
} |
115 |
116 |
} |
} |
116 |
117 |
|
|
|
... |
... |
TEST_CASE("Items with broken timestamps fail to load.", "[item][load]") |
195 |
196 |
{ |
{ |
196 |
197 |
Project prj("tests/data/dit/projects/tmp"); |
Project prj("tests/data/dit/projects/tmp"); |
197 |
198 |
Storage &storage = prj.getStorage(); |
Storage &storage = prj.getStorage(); |
198 |
|
REQUIRE_THROWS_AS(storage.get(id).getValue("c"), std::logic_error); |
|
|
199 |
|
REQUIRE_THROWS_AS(storage.get(id).getValue("c"), |
|
200 |
|
const std::logic_error &); |
199 |
201 |
} |
} |
200 |
202 |
|
|
201 |
203 |
} catch (...) { |
} catch (...) { |
File tests/ItemFilter.cpp changed (mode: 100644) (index eda2bab..acd86cd) |
28 |
28 |
|
|
29 |
29 |
TEST_CASE("Throws on wrong syntax", "[item-filter]") |
TEST_CASE("Throws on wrong syntax", "[item-filter]") |
30 |
30 |
{ |
{ |
31 |
|
REQUIRE_THROWS_AS(ItemFilter({ "wrong expr" }), std::runtime_error); |
|
|
31 |
|
REQUIRE_THROWS_AS(ItemFilter({ "wrong expr" }), const std::runtime_error &); |
32 |
32 |
} |
} |
33 |
33 |
|
|
34 |
34 |
TEST_CASE("Error messages add up", "[item-filter]") |
TEST_CASE("Error messages add up", "[item-filter]") |
File tests/ItemTable.cpp changed (mode: 100644) (index 0795270..fbf2e27) |
... |
... |
TEST_CASE("Throws on wrong specification.", "[item-table][format]") |
30 |
30 |
{ |
{ |
31 |
31 |
REQUIRE_THROWS_AS(ItemTable(std::string(), "this is not valid", |
REQUIRE_THROWS_AS(ItemTable(std::string(), "this is not valid", |
32 |
32 |
std::string(), 80), |
std::string(), 80), |
33 |
|
std::runtime_error); |
|
|
33 |
|
const std::runtime_error &); |
34 |
34 |
} |
} |
35 |
35 |
|
|
36 |
36 |
TEST_CASE("No columns result in no output.", "[item-table][format]") |
TEST_CASE("No columns result in no output.", "[item-table][format]") |
File tests/Storage.cpp changed (mode: 100644) (index 6e56a9c..2b1df94) |
... |
... |
TEST_CASE("Storage throws on save if project removed", "[storage]") |
101 |
101 |
Item &item = storage.get(id); |
Item &item = storage.get(id); |
102 |
102 |
fs::remove_all("tests/data/dit/projects/tmp"); |
fs::remove_all("tests/data/dit/projects/tmp"); |
103 |
103 |
|
|
104 |
|
REQUIRE_THROWS_AS(item.getValue("title"), std::runtime_error); |
|
|
104 |
|
REQUIRE_THROWS_AS(item.getValue("title"), |
|
105 |
|
const std::runtime_error &); |
105 |
106 |
} |
} |
106 |
107 |
|
|
107 |
108 |
} catch (...) { |
} catch (...) { |
File tests/cmds/ExportCmd.cpp changed (mode: 100644) (index 5dac925..5d9e67d) |
... |
... |
TEST_CASE("Item exporting", "[cmds][export]") |
117 |
117 |
SECTION("Failed run") |
SECTION("Failed run") |
118 |
118 |
{ |
{ |
119 |
119 |
REQUIRE_THROWS_AS(cmd->run(*prj, { "no-such-cmd" }), |
REQUIRE_THROWS_AS(cmd->run(*prj, { "no-such-cmd" }), |
120 |
|
std::runtime_error); |
|
|
120 |
|
const std::runtime_error &); |
121 |
121 |
} |
} |
122 |
122 |
|
|
123 |
123 |
REQUIRE(out.str() == std::string()); |
REQUIRE(out.str() == std::string()); |
File tests/file_format.cpp changed (mode: 100644) (index cc85604..8650d3b) |
... |
... |
TEST_CASE("Deserialization of broken stream errors.", "[file-format]") |
44 |
44 |
std::stringstream ss; |
std::stringstream ss; |
45 |
45 |
ss << "bla=bla\n"; |
ss << "bla=bla\n"; |
46 |
46 |
|
|
47 |
|
REQUIRE_THROWS_AS(ss >> d, std::runtime_error); |
|
|
47 |
|
REQUIRE_THROWS_AS(ss >> d, const std::runtime_error &); |
48 |
48 |
} |
} |
49 |
49 |
|
|
50 |
50 |
TEST_CASE("Deserialized objects are identical to original", "[file-format]") |
TEST_CASE("Deserialized objects are identical to original", "[file-format]") |
|
... |
... |
TEST_CASE("Deserialization throws on empty string", "[file-format]") |
71 |
71 |
|
|
72 |
72 |
std::stringstream ss; |
std::stringstream ss; |
73 |
73 |
ss << '\n' << o; |
ss << '\n' << o; |
74 |
|
REQUIRE_THROWS_AS(ss >> d, std::runtime_error); |
|
|
74 |
|
REQUIRE_THROWS_AS(ss >> d, const std::runtime_error &); |
75 |
75 |
} |
} |
76 |
76 |
|
|
77 |
77 |
static inline bool |
static inline bool |
File tests/utils/args.cpp changed (mode: 100644) (index 2000334..b117e17) |
... |
... |
TEST_CASE("Whitespace everywhere", "[utils][args]") |
59 |
59 |
|
|
60 |
60 |
TEST_CASE("Throws exception on unclosed bracket", "[utils][args]") |
TEST_CASE("Throws exception on unclosed bracket", "[utils][args]") |
61 |
61 |
{ |
{ |
62 |
|
REQUIRE_THROWS_AS(breakIntoArgs("'broken"), boost::escaped_list_error); |
|
63 |
|
REQUIRE_THROWS_AS(breakIntoArgs("\"broken"), boost::escaped_list_error); |
|
64 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken'"), boost::escaped_list_error); |
|
65 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\""), boost::escaped_list_error); |
|
|
62 |
|
REQUIRE_THROWS_AS(breakIntoArgs("'broken"), |
|
63 |
|
const boost::escaped_list_error &); |
|
64 |
|
REQUIRE_THROWS_AS(breakIntoArgs("\"broken"), |
|
65 |
|
const boost::escaped_list_error &); |
|
66 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken'"), |
|
67 |
|
const boost::escaped_list_error &); |
|
68 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\""), |
|
69 |
|
const boost::escaped_list_error &); |
66 |
70 |
} |
} |
67 |
71 |
|
|
68 |
72 |
TEST_CASE("Escaping works", "[utils][args]") |
TEST_CASE("Escaping works", "[utils][args]") |
|
... |
... |
TEST_CASE("Escaping works", "[utils][args]") |
73 |
77 |
|
|
74 |
78 |
TEST_CASE("Throws exception on wrong escaping", "[utils][args]") |
TEST_CASE("Throws exception on wrong escaping", "[utils][args]") |
75 |
79 |
{ |
{ |
76 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\\"), boost::escaped_list_error); |
|
77 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\\x"), boost::escaped_list_error); |
|
|
80 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\\"), |
|
81 |
|
const boost::escaped_list_error &); |
|
82 |
|
REQUIRE_THROWS_AS(breakIntoArgs("broken\\x"), |
|
83 |
|
const boost::escaped_list_error &); |
78 |
84 |
} |
} |
79 |
85 |
|
|
80 |
86 |
TEST_CASE("Accepts empty arguments", "[utils][args]") |
TEST_CASE("Accepts empty arguments", "[utils][args]") |