Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecRunResult.h
Go to the documentation of this file.
1#pragma once
2
3#include <Specs/API.h>
4
5#include <memory>
6#include <string>
7#include <string_view>
8
9namespace SpecsCpp {
10
13 std::string _message = "";
14 ISpecComponent* _component;
15 ISpec* _spec;
16 ISpecGroup* _group;
17
18 public:
21 std::string_view message = ""
22 )
23 : _component(component),
24 _group(group),
25 _spec(spec),
26 _status(status),
27 _message(message) {}
28
29 RunResultStatus status() const override { return _status; }
30 const char* message() const override { return _message.c_str(); }
31 ISpecComponent* component() const override { return _component; }
32 ISpec* spec() const override { return _spec; }
33 ISpecGroup* group() const override { return _group; }
34
35 ISpecRunResult* copy() const override {
36 return new SpecRunResult(_component, _group, _spec, _status, _message);
37 }
38
39 inline static std::unique_ptr<SpecRunResult> passed(
41 ) {
42 return std::make_unique<SpecRunResult>(component, group, spec, RunResultStatus::Passed);
43 }
44
45 inline static std::unique_ptr<SpecRunResult> failed(
46 ISpecComponent* component, ISpecGroup* group, ISpec* spec, std::string_view message = ""
47 ) {
48 return std::make_unique<SpecRunResult>(
50 );
51 }
52
53 inline static std::unique_ptr<SpecRunResult> not_run(
55 ) {
56 return std::make_unique<SpecRunResult>(component, group, spec, RunResultStatus::NotRun);
57 }
58
59 inline static std::unique_ptr<SpecRunResult> timeout(
61 ) {
62 return std::make_unique<SpecRunResult>(
64 );
65 }
66 };
67}
const char * message() const override
static std::unique_ptr< SpecRunResult > timeout(ISpecComponent *component, ISpecGroup *group, ISpec *spec)
SpecRunResult(ISpecComponent *component, ISpecGroup *group, ISpec *spec, RunResultStatus status, std::string_view message="")
ISpecComponent * component() const override
static std::unique_ptr< SpecRunResult > passed(ISpecComponent *component, ISpecGroup *group, ISpec *spec)
ISpecGroup * group() const override
static std::unique_ptr< SpecRunResult > not_run(ISpecComponent *component, ISpecGroup *group, ISpec *spec)
static std::unique_ptr< SpecRunResult > failed(ISpecComponent *component, ISpecGroup *group, ISpec *spec, std::string_view message="")
ISpec * spec() const override
ISpecRunResult * copy() const override
RunResultStatus status() const override
Definition API.h:3
RunResultStatus
Definition API.h:165