OTest2
A C++ testing framework
runner.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 #ifndef OTest2__INCLUDE_OTEST2_RUNNER_H_
21 #define OTest2__INCLUDE_OTEST2_RUNNER_H_
22 
23 namespace OTest2 {
24 
40 class RunnerResult {
41  private:
42  bool running;
43  bool result;
44  int delay_ms;
45 
46  public:
50  RunnerResult();
51 
62  bool running_,
63  bool result_,
64  int delay_ms_);
65 
70  const RunnerResult& src_);
71 
75  ~RunnerResult();
76 
80  void swap(
81  RunnerResult& r2_) noexcept;
82 
87  const RunnerResult& src_);
88 
92  bool isFinished() const;
93 
99  int getDelayMS() const;
100 
106  bool getResult() const;
107 };
108 
112 class Runner {
113  public:
114  /* -- avoid copying */
115  Runner(
116  const Runner&) = delete;
118  const Runner&) = delete;
119 
123  Runner();
124 
128  virtual ~Runner();
129 
136  virtual RunnerResult runNext() = 0;
137 };
138 
139 } /* namespace OTest2 */
140 
141 #endif /* OTest2__INCLUDE_OTEST2_RUNNER_H_ */
OTest2::RunnerResult::operator=
RunnerResult & operator=(const RunnerResult &src_)
Copy operator.
Definition: runner.cpp:64
OTest2::Runner::Runner
Runner()
Ctor.
Definition: runner.cpp:85
OTest2::RunnerResult::~RunnerResult
~RunnerResult()
Dtor.
Definition: runner.cpp:53
OTest2::Runner::runNext
virtual RunnerResult runNext()=0
Run next pack of work.
OTest2::RunnerResult::RunnerResult
RunnerResult()
Default ctor - finished failed result.
Definition: runner.cpp:27
OTest2::Runner
Generic test runner.
Definition: runner.h:112
OTest2::Runner::operator=
Runner & operator=(const Runner &)=delete
OTest2
Definition: assertbean.h:25
OTest2::RunnerResult::getDelayMS
int getDelayMS() const
Get delay between two steps in milliseconds.
Definition: runner.cpp:75
OTest2::RunnerResult::isFinished
bool isFinished() const
Check whether the test has already finished.
Definition: runner.cpp:71
OTest2::RunnerResult
Result of test run.
Definition: runner.h:40
OTest2::RunnerResult::getResult
bool getResult() const
Get result of the test - true if the test has passed.
Definition: runner.cpp:80
OTest2::RunnerResult::swap
void swap(RunnerResult &r2_) noexcept
Swap contents.
Definition: runner.cpp:57
OTest2::Runner::~Runner
virtual ~Runner()
Dtor.
Definition: runner.cpp:89