From 8a6e38a6421a60c51c3c2e7fbac60cc5a8df9e8e Mon Sep 17 00:00:00 2001 From: mat007 Date: Thu, 11 Apr 2013 16:23:50 +0000 Subject: [PATCH] Refactoring git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@618 860be788-9bd5-4423-9f1e-828f051e677b --- test/detail/test_function.cpp | 28 ++++++++++++++++++++++++++++ test/mock_error.hpp | 25 ------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index e378a30..4bb2559 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -16,6 +16,34 @@ #include #include +namespace +{ + struct error_fixture + { + error_fixture() + { + data().reset(); + } + ~error_fixture() + { + BOOST_CHECK( data().verify() ); + BOOST_CHECK_EQUAL( 0, data().call_count ); + } + }; +} + +#define CHECK_CALLS( calls ) \ + BOOST_CHECK_EQUAL( calls, data().call_count ); \ + data().call_count = 0; +#define CHECK_ERROR( expr, error, calls, context ) \ + BOOST_CHECK( data().verify() ); \ + try { expr; } catch( ... ) {} \ + BOOST_CHECK_EQUAL( 1, data().error_count ); \ + BOOST_CHECK_EQUAL( error, data().last_message ); \ + BOOST_CHECK_EQUAL( context, data().last_context ); \ + CHECK_CALLS( calls ); \ + data().reset(); + // static namespace diff --git a/test/mock_error.hpp b/test/mock_error.hpp index 7f2d7a8..5730df8 100644 --- a/test/mock_error.hpp +++ b/test/mock_error.hpp @@ -87,31 +87,6 @@ namespace boost::lexical_cast< std::string >( context ), file, line ); } }; - - struct error_fixture - { - error_fixture() - { - data().reset(); - } - ~error_fixture() - { - BOOST_CHECK( data().verify() ); - BOOST_CHECK_EQUAL( 0, data().call_count ); - } - }; } -#define CHECK_CALLS( calls ) \ - BOOST_CHECK_EQUAL( calls, data().call_count ); \ - data().call_count = 0; -#define CHECK_ERROR( expr, error, calls, context ) \ - BOOST_CHECK( data().verify() ); \ - try { expr; } catch( ... ) {} \ - BOOST_CHECK_EQUAL( 1, data().error_count ); \ - BOOST_CHECK_EQUAL( error, data().last_message ); \ - BOOST_CHECK_EQUAL( context, data().last_context ); \ - CHECK_CALLS( calls ); \ - data().reset(); - #endif // MOCK_TEST_MOCK_ERROR_HPP_INCLUDED