OTest2
A C++ testing framework
lib
testroot.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2020 Ondrej Starek
3
*
4
* This file is part of OTest2
5
*
6
* OTest2 is free software: you can redistribute it and/or modify it under
7
* the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License,
9
* or (at your option) any later version.
10
*
11
* OTest2 is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
* License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
testroot.h
>
21
22
#include <assert.h>
23
#include <memory>
24
25
#include <
cmdnextobject.h
>
26
#include <
commandstack.h
>
27
#include <
context.h
>
28
#include <
scenario.h
>
29
30
namespace
OTest2
{
31
32
TestRoot::TestRoot
(
33
const
std::string& name_) :
34
name(name_) {
35
assert(!name.empty());
36
37
}
38
39
TestRoot::~TestRoot
() {
40
41
}
42
43
std::string
TestRoot::getName
()
const
{
44
return
name;
45
}
46
47
bool
TestRoot::startUpObject
(
48
const
Context
& context_,
49
int
index_) {
50
return
false
;
/* -- no start-up functions */
51
}
52
53
void
TestRoot::scheduleBody
(
54
const
Context
& context_,
55
ScenarioPtr
scenario_,
56
ObjectPtr
me_) {
57
ScenarioIterPtr
children_(scenario_->getChildren());
58
context_.
command_stack
->
pushCommand
(
59
std::make_shared<CmdNextObject>(children_, me_));
60
}
61
62
void
TestRoot::tearDownObject
(
63
const
Context
& context_,
64
int
index_) {
65
assert(index_ == 0);
66
/* -- no tear-down functions */
67
}
68
69
}
/* -- namespace OTest2 */
OTest2::TestRoot::startUpObject
virtual bool startUpObject(const Context &context_, int index_) override
Execute start-up function at specified index.
Definition:
testroot.cpp:47
OTest2::CommandStack::pushCommand
void pushCommand(CommandPtr command_)
Push a command into the stack.
Definition:
commandstack.cpp:67
commandstack.h
OTest2::TestRoot::~TestRoot
virtual ~TestRoot()
Dtor.
Definition:
testroot.cpp:39
OTest2::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Shared pointer to a testing object.
Definition:
objectptr.h:27
OTest2::Context::command_stack
CommandStack *const command_stack
Definition:
context.h:40
OTest2
Definition:
assertbean.h:25
OTest2::TestRoot::tearDownObject
virtual void tearDownObject(const Context &context_, int index_) override
Execute tear-down function at specified index.
Definition:
testroot.cpp:62
OTest2::ScenarioIterPtr
std::shared_ptr< ScenarioIter > ScenarioIterPtr
Shared pointer of the scenario iter interface.
Definition:
scenarioiterptr.h:27
OTest2::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Shared pointer of the scenario object.
Definition:
scenarioptr.h:27
testroot.h
OTest2::TestRoot::getName
virtual std::string getName() const override
Get object's name.
Definition:
testroot.cpp:43
scenario.h
context.h
OTest2::TestRoot::TestRoot
TestRoot(const std::string &name_)
Ctor.
Definition:
testroot.cpp:32
OTest2::Context
OTest2 runtime context.
Definition:
context.h:38
cmdnextobject.h
OTest2::TestRoot::scheduleBody
virtual void scheduleBody(const Context &context_, ScenarioPtr scenario_, ObjectPtr me_) override
Schedule body of the testing object.
Definition:
testroot.cpp:53
Generated by
1.8.17