#define assertEquals(msg, expected, actual)\
if ((expected) != (actual)) {\
assertEqualsFailed(msg, ((uint32_t) expected), ((uint32_t) actual), unique(UQ_ASSERTION));\
} else {\
assertSuccess();\
}
So this is some holiday!
expected and actual are evaluated twice!
If you put this macro inside some if-else without nesting in {} you will get very funny things!
Why not:
#define assertEquals(msg, expected, actual) ({\
uint32_t e = expected;\
uint32_t a = actual;\
if (a != e) {\
assertEqualsFailed(msg, e, a, unique(UQ_ASSERTION));\
} else {\
assertSuccess();\
}\
})
Why?!
How to fix it? - use Contiki.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment