mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Refactoring
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@618 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
1f767bc1a4
commit
8a6e38a642
2 changed files with 28 additions and 25 deletions
|
|
@ -16,6 +16,34 @@
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
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
|
// static
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
||||||
|
|
@ -87,31 +87,6 @@ namespace
|
||||||
boost::lexical_cast< std::string >( context ), file, line );
|
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
|
#endif // MOCK_TEST_MOCK_ERROR_HPP_INCLUDED
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue