Menu

#7 Make Assertion Macros Expressions

open
nobody
None
5
2023-07-03
2006-05-12
No

Currently one gets a compile error if they use the
CU_ASSERT macro as an expression. For example:

static void test_dummytest(void)
{
int ret;

ret = 7;
if( ! CU_ASSERT(ret == 7) ) {
    printf("Emergency Clean-up needed.");
}
return;

}

This will return a parse compile error.

If the CU_ASSERT macro was defined as:

define CU_ASSERT(value) \

CU_assertImplementation((value), LINE, #value,
FILE, "", FALSE)

rather than

define CU_ASSERT(value) \

{ CU_assertImplementation((value), LINE, #value,
FILE, "", FALSE);}

The above test would compile and operate correctly.
On the downside, this will force all CU_ASSERT macros
to be terminated with a semi-colon (which is how they
are in all the examples anyway).

Discussion

  • Anil Kumar

    Anil Kumar - 2006-05-12

    Logged In: YES
    user_id=154946

    Would fix in the CVS, would go in next release.

     
  • Anonymous

    Anonymous - 2023-07-03
    Post awaiting moderation.

Anonymous
Anonymous

Add attachments
Cancel