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
24
25
26
27
28
29
#include "crucible/testing/scenario.hpp"

#include "crucible/testing/expect.inl"
#include "crucible/testing/suite.inl"

namespace crucible::testing::scenario {
  Scenario::Scenario(std::string const &group, std::string const &name, ScenarioFunction const &function) :
    my_group { group },
    my_name { name },
    my_function { function } {
  }

  auto Scenario::get_group() const -> std::string {
    return my_group;
  }

  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());
    }
  }
}