Hi, I'm using VAssert and CFIX with template methods like this:
class IncTestsSample : public cfixcc::TestFixture {
public:
template<size_t threadCount, int incCount, int startValue, int maxValue, size_t maxWaitSec>
void Test_Multi_Thread_Increment()
{
static_assert(startValue < maxValue, "initial start value must be less than max value");
static_assert(startValue + incCount < maxValue, "initial start value + increment count must be less than max value");
Multi_Thread_Increment::value = startValue;
Multi_Thread_Increment::IncrementData incData = { incCount, maxValue };
HANDLE tHandles[threadCount];
for (size_t i = 0; i < threadCount; i++) {
tHandles[i] = Multi_Thread_Increment::create_increment_thread(&incData);
}
// wait for threads
DWORD waitRet = WaitForMultipleObjects(threadCount, tHandles, TRUE, 1000 * maxWaitSec);
CFIXCC_ASSERT_EQUALS(DWORD(WAIT_OBJECT_0), waitRet);
}
};
CFIXCC_BEGIN_CLASS( IncTestsSample )
CFIXCC_TEMPLATE_METHOD( Test_Multi_Thread_Increment, 4, 100, 0, INT_MAX/16, 20 )
CFIXCC_TEMPLATE_METHOD( Test_Multi_Thread_Increment, 8, 1000, 0, INT_MAX/8, 10 )
CFIXCC_END_CLASS()
and here is the macro:
#define CFIXCC_TEMPLATE_METHOD( MethodName, ... ) \
{ CfixEntryTypeTestcase, __CFIX_WIDE( #MethodName ) __CFIX_WIDE( ": " ) __CFIX_WIDE ( #__VA_ARGS__ ) , \
cfixcc::InvokeTestMethod< __TestClass, &__TestClass::MethodName < __VA_ARGS__ > > },
I would be glad to see template macros in the next release :-)
Good work!