gamename <namesagame-usenet@[EMAIL PROTECTED]
> writes:
> I use CUnit for testing which uses a variation of "assert()" for
>error detection.
>
>Right now I do multiple asserts to verify multiple values.
>Ex.
> CU_ASSERT(foo==X); CU_ASSERT(foo==Y); CU_ASSERT(foo==Z);
Unless X, Y, and Z are the same, at least two of those are going to fail.
Are
you sure that's what you want to do?
>Is there any way to macro-ize this and do it in one call?
>Ex.
> MYASRT(foo, (X||Y||Z));
> or
> MYASRT(foo,OR,X,Y,Z));
Making a macro of this would only be possible if you called the macro with
the
exact same number of arguments each time, as variable-argument macros are
not
possible in standard C. Assuming that you want a macro that tests foo
against
three values each time, you can do:
#define MYASRT(foo, a, b, c) CU_ASSERT((foo)==(a));
CU_ASSERT((foo)==(b)); \
CU_ASSERT((foo)==(c))
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|