mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-27 00:28:49 +03:00
created SuitePredicate
This commit is contained in:
parent
a6eb17fb48
commit
d584ccfd22
2 changed files with 90 additions and 0 deletions
58
UnitTest++/SuitePredicate.cpp
Normal file
58
UnitTest++/SuitePredicate.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#include "SuitePredicate.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace UnitTest;
|
||||
|
||||
|
||||
SuitePredicate::SuitePredicate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SuitePredicate::~SuitePredicate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SuitePredicate::addSuite(const string & suiteName)
|
||||
{
|
||||
_suiteNames.push_back(suiteName);
|
||||
}
|
||||
|
||||
|
||||
void SuitePredicate::addTest(const string & testName)
|
||||
{
|
||||
_testNames.push_back(testName);
|
||||
}
|
||||
|
||||
|
||||
bool SuitePredicate::operator()(Test const * const test) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
32
UnitTest++/SuitePredicate.h
Normal file
32
UnitTest++/SuitePredicate.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef UNITTEST_SUITEPREDICATE_H
|
||||
#define UNITTEST_SUITEPREDICATE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Test.h"
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
class SuitePredicate
|
||||
{
|
||||
public:
|
||||
SuitePredicate();
|
||||
virtual ~SuitePredicate();
|
||||
|
||||
void addSuite(const string & suiteName);
|
||||
void addTest(const string & testName);
|
||||
|
||||
bool operator()(Test const * const test) const;
|
||||
|
||||
private:
|
||||
bool mustExecuteSuite(Test const * const test) const;
|
||||
bool mustExecuteTest(Test const * const test) const;
|
||||
|
||||
vector<string> _suiteNames;
|
||||
vector<string> _testNames;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue