Skip to content

Commit

Permalink
Fix #23 - Add proper parens in expect macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Jan 11, 2021
1 parent e65b9eb commit 924d92c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/tts/tts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ namespace tts
#define TTS_EXPECT(EXPR) \
do \
{ \
::tts::result tts_var_d = TTS_DECOMPOSE(EXPR); \
::tts::result tts_var_d = TTS_DECOMPOSE((EXPR)); \
if(tts_var_d) \
{ \
TTS_PASS("Expecting: " << ::tts::green(TTS_STRING(EXPR)) ); \
Expand All @@ -769,7 +769,7 @@ namespace tts
#define TTS_EXPECT_NOT(EXPR) \
do \
{ \
::tts::result tts_var_d = TTS_DECOMPOSE(EXPR); \
::tts::result tts_var_d = TTS_DECOMPOSE((EXPR)); \
if(tts_var_d) \
{ \
TTS_FAIL( "Not Expecting: " << ::tts::green(TTS_STRING(EXPR)) << " but " << ::tts::red() \
Expand Down
4 changes: 3 additions & 1 deletion test/basic/expect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

TTS_CASE( "Check that expectation can be met" )
{
int a = 42, b = 69;
int a = 43, b = 69;

TTS_EXPECT(a != b);
TTS_EXPECT(a < b);
TTS_EXPECT(a <= b);
TTS_EXPECT(b > a);
TTS_EXPECT(b >= a);

TTS_EXPECT( a & b );
}

constexpr bool eq (int a, int b) { return a == b; }
Expand Down
3 changes: 2 additions & 1 deletion test/basic/expect_not.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ TTS_CASE( "Check that counter-expectation can be met" )
TTS_EXPECT_NOT(a >= b);
TTS_EXPECT_NOT(b < a);
TTS_EXPECT_NOT(b <= a);

TTS_EXPECT_NOT(b & a);
}

constexpr bool eq (int a, int b) { return a == b; }
Expand All @@ -36,4 +38,3 @@ TTS_CASE( "Check that constexpr counter-expectation can be met" )
TTS_CONSTEXPR_EXPECT_NOT(lte(69, 42));
TTS_CONSTEXPR_EXPECT_NOT(gte(42, 69));
}

0 comments on commit 924d92c

Please sign in to comment.