mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Run a named unit test
This commit is contained in:
@@ -105,6 +105,33 @@ void UnitTests::resultsUpdated()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnitTests::runTest (String const& name)
|
||||||
|
{
|
||||||
|
results.clear();
|
||||||
|
resultsUpdated();
|
||||||
|
|
||||||
|
Array<UnitTest*>& tests = UnitTest::getAllTests ();
|
||||||
|
|
||||||
|
for (int i = 0; i < tests.size(); ++i)
|
||||||
|
{
|
||||||
|
UnitTest& test = *tests [i];
|
||||||
|
|
||||||
|
if (test.getName () == name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
test.performTest (this);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
addFail ("An unhandled exception was thrown!");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UnitTests::runTests (const Array<UnitTest*>& tests)
|
void UnitTests::runTests (const Array<UnitTest*>& tests)
|
||||||
{
|
{
|
||||||
results.clear();
|
results.clear();
|
||||||
|
|||||||
@@ -56,9 +56,10 @@ class UnitTests;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Explicit template instantiation is required to make the unit
|
// This makes the unit test available in the global list
|
||||||
// test get automatically added to the set of unit tests.
|
// It doesn't have to be static.
|
||||||
template class UnitTestType <MyTest>;
|
//
|
||||||
|
static MyTest myTest;
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@@ -187,6 +188,10 @@ public:
|
|||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
virtual ~UnitTests();
|
virtual ~UnitTests();
|
||||||
|
|
||||||
|
/** Run a particular test.
|
||||||
|
*/
|
||||||
|
void runTest (String const& name);
|
||||||
|
|
||||||
/** Runs a set of tests.
|
/** Runs a set of tests.
|
||||||
|
|
||||||
The tests are performed in order, and the results are logged. To run all the
|
The tests are performed in order, and the results are logged. To run all the
|
||||||
|
|||||||
Reference in New Issue
Block a user