Menu

#2 ASSERT_EQUALS_NUMBER and ASSERT_NOT_EQUALS_NUMBER

open
nobody
None
5
2010-08-31
2010-08-31
No

The "ASSERT_EQUALS" and "not ASSERT_NOT_EQUALS" macroses are good as can be used to compare any objects. But for integers they don't show actual values like "ASSERT_GREATER".
Existing float comparing could be used instead, but it always shows many digits after the dot and is decimal.
I offer new macroses that check equallity of hexadecimal numbers and show result. They can be used to compare error codes, for example.

// Asserts that a == b
#define ASSERT_EQUALS_NUMBER(a, b) \ TEST(#a " is supposed to equal " #b); \ sprintf_s(info, "\n\t(a == 0x%x, b == 0x%x)", (a), (b)); \ ASSERT((a) == (b));

// Asserts that a != b
#define ASSERT_NOT_EQUALS_NUMBER(a, b) \ TEST(#a " is not supposed to equal " #b); \ sprintf_s(info, "\n\t(a == 0x%x, b == 0x%x)", (a), (b)); \ ASSERT((a) != (b));

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.