I had a test like this:
for(int i = 0; i < arrsize; i++) {
x[i] = i;
}
for(int i = 0; i < arrsize; i++) {
CPPUNIT_ASSERT(x[i] == i);
}
and noticed it was REALLY TOO SLOW.
I figured out what's the point: CPPUNIT_ASSERT always
calls CPPUNIT_NS::Asserter::failIf passing two
std::string as parameters, so the compiler wasn't
optimizing the string construction (and constructing
two strings everytime).
IMHO this can be solved in 2 ways:
1) changing failIf parameters to const char *
2) modifying CPPUNIT_ASSERT this way:
#define CPPUNIT_ASSERT(condition) \ { if (!condition) \ CPPUNIT_NS::Asserter::fail( \ CPPUNIT_NS::Message("assertion failed", \ "Expression: " #condition), \ CPPUNIT_SOURCELINE() \ ); \ }
I have tested the latter solution and it's working
(and running fast) in my case.
Thank you in advance