mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-27 00:28:49 +03:00
69 lines
1,000 B
C++
69 lines
1,000 B
C++
#include "SuitePredicate.h"
|
|
|
|
using namespace std;
|
|
using namespace UnitTest;
|
|
|
|
|
|
SuitePredicate::SuitePredicate()
|
|
: _all(false)
|
|
{
|
|
}
|
|
|
|
|
|
SuitePredicate::~SuitePredicate()
|
|
{
|
|
}
|
|
|
|
|
|
void SuitePredicate::addSuite(char const* suiteName)
|
|
{
|
|
_suiteNames.push_back(suiteName);
|
|
}
|
|
|
|
|
|
void SuitePredicate::addTest(char const* testName)
|
|
{
|
|
_testNames.push_back(testName);
|
|
}
|
|
|
|
|
|
void SuitePredicate::addAll()
|
|
{
|
|
_all = true;
|
|
}
|
|
|
|
|
|
bool SuitePredicate::operator()(Test const * const test) const
|
|
{
|
|
if (_all)
|
|
{
|
|
return true;
|
|
}
|
|
return (mustExecuteSuite(test) || mustExecuteTest(test));
|
|
}
|
|
|
|
|
|
bool SuitePredicate::mustExecuteSuite(Test const * const test) const
|
|
{
|
|
for (size_t i = 0; i < _suiteNames.size(); i++)
|
|
{
|
|
if (_suiteNames[i] == test->m_details.suiteName)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
bool SuitePredicate::mustExecuteTest(Test const * const test) const
|
|
{
|
|
for (size_t i = 0; i < _testNames.size(); i++)
|
|
{
|
|
if (_testNames[i] == test->m_details.testName)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|