scenario.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "crucible/test/scenario.hpp" #include "crucible/test/expect.hpp" #include "crucible/test/suite.hpp" namespace crucible::test::scenario { Scenario::Scenario(std::string const &name, ScenarioFunction const &function) : my_name(name), my_function(function) { } auto Scenario::get_name() const -> std::string { return my_name; } auto Scenario::execute() -> outcome::Outcome { try { my_function(); return outcome::make_pass(); } catch (expect::ExpectFailed const &e) { return outcome::make_fail(e.what()); } } ScenarioRegistrar::ScenarioRegistrar(std::string const &name, ScenarioFunction const &test) { auto &suite = suite::Suite::get_reference(); suite.add_scenario(name, test); } }