Skip to content

Commit

Permalink
Add BEAST_EXPECT macro:
Browse files Browse the repository at this point in the history
This macro is used in the unit test framework to assist in
reporting the file and line number of test failures.
  • Loading branch information
vinniefalco committed Aug 3, 2016
1 parent 8204d95 commit 73a28ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions extras/beast/unit_test/suite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ suite::run (runner& r)
}
}

#ifndef BEAST_EXPECT
/** Check a precondition.
*/
#define BEAST_EXPECT_S1(x) #x
#define BEAST_EXPECT_S2(x) BEAST_EXPECT_S1(x)
#define BEAST_EXPECT(cond) expect(cond, __FILE__ ":" BEAST_EXPECT_S2(__LINE__))
#endif

} // unit_test
} // beast

Expand Down
4 changes: 2 additions & 2 deletions test/core/detail/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class base64_test : public beast::unit_test::suite
check (std::string const& in, std::string const& out)
{
auto const encoded = base64_encode (in);
expect (encoded == out);
expect (base64_decode (encoded) == in);
expect(encoded == out);
expect(base64_decode (encoded) == in);
}

void
Expand Down
6 changes: 3 additions & 3 deletions test/core/detail/empty_base_optimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class empty_base_optimization_test
void
run ()
{
expect (test_one());
expect (test_two());
pass ();
expect(test_one());
expect(test_two());
pass();
}
};

Expand Down

0 comments on commit 73a28ca

Please sign in to comment.