宏可以这样做吗? [英] Can A Macro Do This?
问题描述
嗨
现在我做多个断言来验证多个值:
断言(foo == X);
断言(foo == Y);
断言(foo == Z);
有没有办法宏观化这个并在一个电话?
MYASRT(foo,(X || Y || Z));
...或者......
MYASRT(foo,OR,X,Y,Z));
TIA,
-T
Hi
Right now I do multiple asserts to verify multiple values:
assert(foo==X);
assert(foo==Y);
assert(foo==Z);
Is there any way to macro-ize this and do it in one call?
MYASRT(foo, (X||Y||Z));
... or maybe...
MYASRT(foo,OR,X,Y,Z));
TIA,
-T
推荐答案
gamename写道:
gamename wrote:
嗨
现在我做多个断言来验证多个值:
断言(foo == X);
断言(foo == Y);
断言(foo == Z);
有没有办法宏观化这个并在一次通话中完成?
MYASRT(foo,(X || Y || Z)) ;
...或者......
MYASRT(foo,OR,X,Y,Z));
Hi
Right now I do multiple asserts to verify multiple values:
assert(foo==X);
assert(foo==Y);
assert(foo==Z);
Is there any way to macro-ize this and do it in one call?
MYASRT(foo, (X||Y||Z));
... or maybe...
MYASRT(foo,OR,X,Y,Z));
出了什么问题:
断言(foo == X || foo == Y || foo == Z);
What''s wrong with:
assert(foo == X || foo == Y || foo == Z);
santosh写道:
santosh wrote:
gamename写道:
gamename wrote:
>嗨
现在我做多个断言来验证多个值:
断言(foo == X);
断言(foo = = Y);
断言(foo == Z);
有没有办法宏观化这个并在一次通话中完成?
MYASRT(foo,(X || Y || Z));
......或者......
MYASRT(foo,OR,X,Y,Z));
>Hi
Right now I do multiple asserts to verify multiple values:
assert(foo==X);
assert(foo==Y);
assert(foo==Z);
Is there any way to macro-ize this and do it in one call?
MYASRT(foo, (X||Y||Z));
... or maybe...
MYASRT(foo,OR,X,Y,Z));
出了什么问题:
断言(foo == X || foo == Y || foo == Z);
What''s wrong with:
assert(foo == X || foo == Y || foo == Z);
这是错误的!
应该是:
断言( foo == X&& foo == Y&& foo == Z);
-
jacob navia
jacob at jacob point remcomp point fr
logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32
jacob navia写道:
jacob navia wrote:
santosh写道:
santosh wrote:
> gamename写道:
>gamename wrote:
>>嗨
现在我做多个断言来验证多个值:
断言(foo == X);
断言(foo == Y);
assert(foo == Z);
有没有办法宏观化这个并在一次调用中完成它?
MYASRT(foo,(X || Y || Z) ));
......或者可能是...
MYASRT(foo,OR,X,Y,Z));
>>Hi
Right now I do multiple asserts to verify multiple values:
assert(foo==X);
assert(foo==Y);
assert(foo==Z);
Is there any way to macro-ize this and do it in one call?
MYASRT(foo, (X||Y||Z));
... or maybe...
MYASRT(foo,OR,X,Y,Z));
有什么问题:
断言(foo == X || foo == Y || foo == Z);
What''s wrong with:
assert(foo == X || foo == Y || foo == Z);
这是错误的!
应该是:
断言(foo == X && foo == Y&& foo == Z);
That is wrong!
Should be:
assert(foo == X && foo == Y && foo == Z);
否则是。你是对的。
在我的辩护中,我被MYASRT所左右。由
OP呈现的宏,他使用OR运算符而不是AND。
Oops yes. You are right.
In my defence I got sidetracked by the "MYASRT" macro presented by the
OP, where he uses the OR operator, instead of the AND.
这篇关于宏可以这样做吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!