mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Return results of expect in UnitTest
This commit is contained in:
@@ -106,7 +106,7 @@ void UnitTest::beginTestCase (String const& name)
|
|||||||
m_case = new Case (name, m_className);
|
m_case = new Case (name, m_className);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::expect (bool trueCondition, String const& failureMessage)
|
bool UnitTest::expect (bool trueCondition, String const& failureMessage)
|
||||||
{
|
{
|
||||||
if (trueCondition)
|
if (trueCondition)
|
||||||
{
|
{
|
||||||
@@ -116,9 +116,11 @@ void UnitTest::expect (bool trueCondition, String const& failureMessage)
|
|||||||
{
|
{
|
||||||
fail (failureMessage);
|
fail (failureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return trueCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::unexpected (bool falseCondition, String const& failureMessage)
|
bool UnitTest::unexpected (bool falseCondition, String const& failureMessage)
|
||||||
{
|
{
|
||||||
if (! falseCondition)
|
if (! falseCondition)
|
||||||
{
|
{
|
||||||
@@ -128,6 +130,8 @@ void UnitTest::unexpected (bool falseCondition, String const& failureMessage)
|
|||||||
{
|
{
|
||||||
fail (failureMessage);
|
fail (failureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ! falseCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::pass ()
|
void UnitTest::pass ()
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public:
|
|||||||
If Suite is true, a pass is logged; if it's false, a failure is logged.
|
If Suite is true, a pass is logged; if it's false, a failure is logged.
|
||||||
If the failure message is specified, it will be written to the log if the test fails.
|
If the failure message is specified, it will be written to the log if the test fails.
|
||||||
*/
|
*/
|
||||||
void expect (bool trueCondition, String const& failureMessage = String::empty);
|
bool expect (bool trueCondition, String const& failureMessage = String::empty);
|
||||||
|
|
||||||
/** Checks that the result of a test is false, and logs this result.
|
/** Checks that the result of a test is false, and logs this result.
|
||||||
|
|
||||||
@@ -270,13 +270,13 @@ public:
|
|||||||
|
|
||||||
@see expect
|
@see expect
|
||||||
*/
|
*/
|
||||||
void unexpected (bool falseCondition, String const& failureMessage = String::empty);
|
bool unexpected (bool falseCondition, String const& failureMessage = String::empty);
|
||||||
|
|
||||||
/** Compares two values, and if they don't match, prints out a message containing the
|
/** Compares two values, and if they don't match, prints out a message containing the
|
||||||
expected and actual result values.
|
expected and actual result values.
|
||||||
*/
|
*/
|
||||||
template <class ActualType, class ExpectedType>
|
template <class ActualType, class ExpectedType>
|
||||||
void expectEquals (ActualType actual, ExpectedType expected, String failureMessage = String::empty)
|
bool expectEquals (ActualType actual, ExpectedType expected, String failureMessage = String::empty)
|
||||||
{
|
{
|
||||||
const bool result = (actual == expected);
|
const bool result = (actual == expected);
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ public:
|
|||||||
failureMessage << "Expected value: " << expected << ", Actual value: " << actual;
|
failureMessage << "Expected value: " << expected << ", Actual value: " << actual;
|
||||||
}
|
}
|
||||||
|
|
||||||
expect (result, failureMessage);
|
return expect (result, failureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Causes the test item to pass. */
|
/** Causes the test item to pass. */
|
||||||
|
|||||||
Reference in New Issue
Block a user