What means #define TEST_CASE(...)

1.3k views Asked by At

What does this definition mean

#define TEST_CASE(...)

in Unity C test harness?

Then it is used this way (example):

TEST_CASE(0)
TEST_CASE(44)
TEST_CASE((90)+9)
void test_TheseShouldAllPass(int Num)
{
    TEST_ASSERT_TRUE(Num < 100);
}

More about Unity here : http://throwtheswitch.org/white-papers/unity-intro.html

1

There are 1 answers

3
Jiminion On

It's a unity pre-processor call to generate test cases for the following test example. The code compiles (or pre-compiles) to:

test_TheseShouldAllPass(0);
test_TheseShouldAllPass(44);
test_TheseShouldAllPass(99);

Some more info:

If the identifier list does not end with an ellipsis, the number of arguments in a macro invocation must be the same as the number of parameters in the corresponding macro definition. During parameter substitution, any arguments remaining after all specified arguments have been substituted (including any separating commas) are combined into one argument called the variable argument. The variable argument will replace any occurrence of the identifier VA_ARGS in the replacement list. The following example illustrates this:

#define debug(...)   fprintf(stderr, __VA_ARGS__)

debug("flag");     /*   Becomes fprintf(stderr, "flag");   */