8#ifndef META_OCEAN_TEST_TEST_RESULT_H
9#define META_OCEAN_TEST_TEST_RESULT_H
80 [[nodiscard]]
inline bool succeeded()
const;
98 [[nodiscard]]
inline const std::string&
testName()
const;
142 ocean_assert(
succeededChecked_ &&
"The test result has not been checked via succeeded()");
204 stream << testResult.
testName() <<
": ";
209 stream <<
"succeeded.";
217 stream <<
"No test was executed!";
230template <
bool tActive>
233 if (!testResult.testName().empty())
235 messageObject << testResult.testName() <<
": ";
238 if (testResult.succeededSoFar())
240 messageObject <<
"succeeded.";
242 else if (testResult.anyTestExecuted())
244 messageObject <<
"FAILED!";
248 messageObject <<
"No test was executed!";
251 return messageObject;
261template <
bool tActive>
262MessageObject<tActive>&
operator<<(MessageObject<tActive>&& messageObject,
const TestResult& testResult)
264 if (!testResult.testName().empty())
266 messageObject << testResult.testName() <<
": ";
269 if (testResult.succeededSoFar())
271 messageObject <<
"succeeded.";
273 else if (testResult.anyTestExecuted())
275 messageObject <<
"FAILED!";
279 messageObject <<
"No test was executed!";
282 return messageObject;
static MessageObject info()
Returns the message for information messages.
Definition Messenger.h:1085
Messenger object, one object for each message.
Definition Messenger.h:448
This class implements a simple test result accumulator.
Definition TestResult.h:47
TestResult()=default
Default constructor.
TestResult(TestResult &&)=delete
Disabled move constructor.
~TestResult()
Destructs this test result object.
Definition TestResult.h:139
bool succeeded() const
Returns whether this test result has succeeded.
Definition TestResult.h:170
bool anyTestExecuted_
True if at least one test was executed.
Definition TestResult.h:131
bool anyTestExecuted() const
Returns whether any test was executed.
Definition TestResult.h:184
bool succeededChecked_
True if the success state of this result has been checked via succeeded().
Definition TestResult.h:135
TestResult & operator=(TestResult &&)=delete
Disabled move assignment operator.
bool succeededSoFar() const
Returns whether this test result has succeeded so far without marking it as checked.
Definition TestResult.h:179
TestResult & operator=(bool value)
Assignment operator for bool values.
Definition TestResult.h:157
TestResult(const TestResult &)=delete
Disabled copy constructor.
TestResult & operator=(const TestResult &)=delete
Disabled copy assignment operator.
std::string testName_
The name of the test.
Definition TestResult.h:125
const std::string & testName() const
Returns the name of the test.
Definition TestResult.h:189
bool succeeded_
True if the test has succeeded; false if any test has failed.
Definition TestResult.h:128
std::ostream & operator<<(std::ostream &stream, const TestResult &testResult)
Writes a test result to a stream.
Definition TestResult.h:200
The namespace covering the entire Ocean framework.
Definition Accessor.h:15