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);
So you're asserting that foo, X, Y, and Z are all equal to each other.
> 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));
Your use of "||" or "OR" implies that you want to check that foo is
equal to just one of X, Y, or Z.
Once you've decided whether foo needs to be equal to all of X, Y, and
Z or to just one of them, you can write:
CU_ASSERT(foo==X && foo==Y && foo==Z);
or
CU_ASSERT(foo==X || foo==Y || foo==Z);
(I'm assuming that CU_ASSERT works similarly to the standard assert()
macro.)
--
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
--
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.


|