Echo Writes Code

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
#include "crucible/test/scenario.hpp"

#include "crucible/test/expect.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() const -> outcome::Outcome {
    try {
      my_function();
      return outcome::make_pass();
    } catch (expect::ExpectFailed const &e) {
      return outcome::make_fail(e.what());
    }
  }
}