Echo Writes Code

reporter.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "crucible/test/reporter.hpp"

#include "crucible/core/assert.hpp"
#include "crucible/test/console_reporter.hpp"

namespace crucible
{
  Reporter::Reporter(std::unique_ptr<AbstractReporter> implementation) :
    my_implementation { std::move(implementation) }
  {}

  auto Reporter::handle_empty_suite(std::string const &name) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_empty_suite(name);
  }

  auto Reporter::handle_suite_start(std::string const &name) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_suite_start(name);
  }

  auto Reporter::handle_group_start(std::string const &group) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_group_start(group);
  }

  auto Reporter::handle_group_end(std::string const &group) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_group_end(group);
  }

  auto Reporter::handle_suite_end(std::size_t const pass_count, std::size_t const fail_count, std::size_t const scenario_count, std::size_t const fixture_count) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_suite_end(pass_count, fail_count, scenario_count, fixture_count);
  }

  auto Reporter::handle_scenario_start(Scenario const &scenario) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_scenario_start(scenario);
  }

  auto Reporter::handle_scenario_end(Scenario const &scenario, Outcome const &outcome) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_scenario_end(scenario, outcome);
  }

  auto Reporter::handle_fixture_start(Fixture const &fixture) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_fixture_start(fixture);
  }

  auto Reporter::handle_fixture_end(Fixture const &fixture, Outcome const &outcome) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->handle_fixture_end(fixture, outcome);
  }

  auto Reporter::set_show_fixtures(bool const show_fixtures) -> void
  {
    CRUCIBLE_ASSERT_NE(my_implementation, nullptr);
    my_implementation->set_show_fixtures(show_fixtures);
  }

  auto make_console_reporter() -> Reporter
  {
    return Reporter { std::make_unique<ConsoleReporter>() };
  }
}