Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Stupid Macr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 1034 of 1133
Post > Topic >>

Re: Stupid Macro Tricks Query

by Keith Thompson <kst-u@[EMAIL PROTECTED] > Jan 14, 2008 at 12:49 PM

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.
 




 4 Posts in Topic:
Stupid Macro Tricks Query
gamename <namesagame-u  2008-01-12 19:02:05 
Re: Stupid Macro Tricks Query
Keith Thompson <kst-u@  2008-01-14 12:49:14 
Re: Stupid Macro Tricks Query
Minimiscience <minimis  2008-01-14 12:50:25 
Re: Stupid Macro Tricks Query
Keith Thompson <kst-u@  2008-02-17 12:03:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:01:34 CDT 2008.