method for check if it is twice the same test from TestDetails

This commit is contained in:
Gabriel Schlozer 2016-06-15 11:36:27 +02:00
parent 724c803bd5
commit ec13c8d140
2 changed files with 27 additions and 0 deletions

View file

@ -1,4 +1,5 @@
#include "TestDetails.h"
#include <cstring>
namespace UnitTest {
@ -18,5 +19,29 @@ namespace UnitTest {
, timeConstraintExempt(details.timeConstraintExempt)
{}
bool TestDetails::sameTest(const TestDetails & details) const
{
if (&details == this)
{
return true;
}
// Fast pointer comparison
if (details.suiteName == suiteName &&
details.testName == testName &&
details.filename == filename)
{
return true;
}
// Long string comparison
if (!strcmp(details.suiteName, suiteName) &&
!strcmp(details.testName, testName) &&
!strcmp(details.filename, filename))
{
return true;
}
return false;
}
}

View file

@ -17,6 +17,8 @@ namespace UnitTest {
int const lineNumber;
mutable bool timeConstraintExempt;
bool sameTest(const TestDetails & details) const;
TestDetails(TestDetails const&); // Why is it public? --> http://gcc.gnu.org/bugs.html#cxx_rvalbind
private:
TestDetails& operator=(TestDetails const&);