OTest2
A C++ testing framework
runner.cpp
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 #include <runner.h>
21 
22 #include <algorithm>
23 #include <assert.h>
24 
25 namespace OTest2 {
26 
28  running(false),
29  result(false),
30  delay_ms(-1) {
31 
32 }
33 
35  bool running_,
36  bool result_,
37  int delay_ms_) :
38  running(running_),
39  result(result_),
40  delay_ms(delay_ms_) {
41  assert((running && delay_ms >= 0) || (!running_));
42 
43 }
44 
46  const RunnerResult& src_) :
47  running(src_.running),
48  result(src_.result),
49  delay_ms(src_.delay_ms) {
50 
51 }
52 
54 
55 }
56 
58  RunnerResult& r2_) noexcept {
59  std::swap(running, r2_.running);
60  std::swap(result, r2_.result);
61  std::swap(delay_ms, r2_.delay_ms);
62 }
63 
65  const RunnerResult& src_) {
66  RunnerResult tmp_(src_);
67  swap(tmp_);
68  return *this;
69 }
70 
72  return !running;
73 }
74 
76  assert(running);
77  return delay_ms;
78 }
79 
81  assert(!running);
82  return result;
83 }
84 
86 
87 }
88 
90 
91 }
92 
93 } /* namespace OTest2 */
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::RunnerResult::RunnerResult
RunnerResult()
Default ctor - finished failed result.
Definition: runner.cpp:27
OTest2
Definition: assertbean.h:25
OTest2::RunnerResult::getDelayMS
int getDelayMS() const
Get delay between two steps in milliseconds.
Definition: runner.cpp:75
runner.h
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