mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
Merge pull request #3596 from pocoproject/poco-1.12-cppunit-improvements
CppUnit: add generic assertEquals
This commit is contained in:
commit
2cccd9fede
@ -124,10 +124,15 @@ protected:
|
||||
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(long expected,
|
||||
long actual,
|
||||
template <typename T1, typename T2>
|
||||
void assertEquals(T1 expected,
|
||||
T2 actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
void assertEquals(double expected,
|
||||
double actual,
|
||||
@ -140,13 +145,22 @@ protected:
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const char* expected,
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const void* expected,
|
||||
const void* actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
std::string notEqualsMessage(long expected, long actual);
|
||||
std::string notEqualsMessage(double expected, double actual);
|
||||
template <typename T1, typename T2>
|
||||
std::string notEqualsMessage(T1 expected, T2 actual)
|
||||
{
|
||||
return "expected: " + std::to_string(expected) + " but was: " + std::to_string(actual);
|
||||
}
|
||||
|
||||
std::string notEqualsMessage(const void* expected, const void* actual);
|
||||
std::string notEqualsMessage(const std::string& expected, const std::string& actual);
|
||||
|
||||
|
@ -47,14 +47,6 @@ void TestCase::loop2assertImplementation(bool condition, const std::string& cond
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(long expected, long actual, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(double expected, double actual, double delta, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
@ -79,6 +71,14 @@ void TestCase::assertEquals(const std::string& expected, const std::string& actu
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(const char* expected, const std::string& actual, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (std::string(expected) != actual)
|
||||
assertImplementation(false, notEqualsMessage(std::string(expected), actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::assertNotNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (pointer == NULL)
|
||||
@ -152,20 +152,6 @@ void TestCase::runTest()
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(long expected, long actual)
|
||||
{
|
||||
return "expected: " + estring(expected) + " but was: " + estring(actual);
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(double expected, double actual)
|
||||
{
|
||||
return "expected: " + estring(expected) + " but was: " + estring(actual);
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(const void* expected, const void* actual)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user