Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecTest.h
Go to the documentation of this file.
1#pragma once
2
3#include <Specs/API.h>
4#include <string_format.h>
5
6#include <memory>
7#include <string>
8#include <string_view>
9
10#include "SpecCodeBlock.h"
11#include "SpecComponent.h"
12#include "SpecDocumented.h"
13#include "SpecHasCodeBlock.h"
15
16namespace SpecsCpp {
17
18 class SpecTest : public ISpec,
19 public SpecComponent,
20 public SpecDocumented,
21 public SpecHasCodeBlock {
22 std::string _fullDescription;
23 std::unique_ptr<SpecVariableCollection> _variables =
24 std::make_unique<SpecVariableCollection>();
25
26 public:
28 ISpecGroup* parent, std::string_view description,
29 std::unique_ptr<SpecCodeBlock> codeBlock
30 )
33 SpecHasCodeBlock(std::move(codeBlock)) {
34 if (parent == nullptr || strlen(parent->full_description()) == 0)
35 _fullDescription = description;
36 else
37 _fullDescription =
38 string_format("{} > {}", parent->full_description(), description);
39 }
40
41 const char* full_description() const override { return _fullDescription.c_str(); }
42
43 ISpecVariableCollection* variables() const override { return _variables.get(); }
44 };
45}
const char * description() const override
const char * full_description() const override
Definition SpecTest.h:41
SpecTest(ISpecGroup *parent, std::string_view description, std::unique_ptr< SpecCodeBlock > codeBlock)
Definition SpecTest.h:27
ISpecVariableCollection * variables() const override
Definition SpecTest.h:43
Definition API.h:3
SpecComponentType
Definition API.h:128
virtual const char * full_description() const =0
virtual IVoidPointer * get(const char *name) const =0