Skip to content

Commit

Permalink
Add support for asserting on long long values: define CTEST_LONG_LONG…
Browse files Browse the repository at this point in the history
…_ASSERT before including ctassert.h.
  • Loading branch information
Scott Bronson committed Jun 27, 2008
1 parent d78ea9f commit 820c845
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Would be nice but might never happen:
- "A test could crash and fool the framework into thinking that it passed!"
- Erm, you're probably more likely to be hit by lightning.
- This would allow the ability to specify an optional timeout.
- Add tests for CTEST_LONG_LONG_ASSERTS? Do it in a different file of course.
- AssertStrEmpty and AssertStrNonEmpty suck. Clean them up?
- It won't be easy... They work well.
- Make it easy to temporarily disable tests.
Expand Down
21 changes: 17 additions & 4 deletions ctassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,23 @@
} while(0)


#define AssertOp(x,op,y) AssertExpType(x,op,y,long,"%ld")
#define AssertHexOp(x,op,y) AssertExpType(x,op,y,long,"0x%lX")
#define AssertOpToZero(x,op) AssertExpToZero(x,op,long,"%ld")
#define AssertHexOpToZero(x,op) AssertExpToZero(x,op,long,"0x%lX")
/* define CTEST_LONG_LONG_ASSERTS before including ctassert.h to have all
* integer comparisons done using long longs. Define this if you ever
* need to assert on 64 bit values on 32 bit systems. It incurs a
* small performance penalty and is hardly ever needed. */

#ifdef CTEST_LONG_LONG_ASSERTS
#define CTiLONG long long
#define CTiFMT "%ll"
#else
#define CTiLONG long
#define CTiFMT "%l"
#endif

#define AssertOp(x,op,y) AssertExpType(x,op,y,CTiLONG,CTiFMT"d")
#define AssertHexOp(x,op,y) AssertExpType(x,op,y,CTiLONG,"0x"CTiFMT"X")
#define AssertOpToZero(x,op) AssertExpToZero(x,op,CTiLONG,CTiFMT"d")
#define AssertHexOpToZero(x,op) AssertExpToZero(x,op,CTiLONG,"0x"CTiFMT"X")
#define AssertPtrOp(x,op,y) AssertExpType(x,op,y,void*,"0x%lX") /* can't use %p because some libc print "0x" first and some don't */
#define AssertFloatOp(x,op,y) AssertExpType(x,op,y,double,"%lf")
#define AssertStrOp(x,opn,op,y) do { char *xv = (void*)(x); char *yv = (void*)(y); \
Expand Down

0 comments on commit 820c845

Please sign in to comment.