mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Error policy now customizable and missing result specifications now reported with file name and line
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@67 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
51379e7844
commit
6ff9fc5564
14 changed files with 380 additions and 271 deletions
|
|
@ -6,36 +6,26 @@
|
|||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include <turtle/object.hpp>
|
||||
#include <turtle/expectation.hpp>
|
||||
#include "silent_error.hpp"
|
||||
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#define BOOST_LIB_NAME boost_unit_test_framework
|
||||
#include <boost/config/auto_link.hpp>
|
||||
|
||||
#define MOCK_ERROR_POLICY silent_error
|
||||
#include <turtle/object.hpp>
|
||||
#include <turtle/expectation.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( verifying_an_empty_object_succeeds )
|
||||
{
|
||||
mock::object o;
|
||||
BOOST_CHECK( o.verify() );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct silent_error
|
||||
{
|
||||
static void verification_failed( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
static void untriggered_expectation( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( verifying_an_object_containing_a_failing_expectation_fails )
|
||||
{
|
||||
mock::object o;
|
||||
mock::expectation< void(), silent_error > e;
|
||||
mock::expectation< void() > e;
|
||||
o.set_parent( e );
|
||||
e.expect().once();
|
||||
BOOST_CHECK( ! o.verify() );
|
||||
|
|
@ -46,7 +36,7 @@ BOOST_AUTO_TEST_CASE( verifying_an_object_containing_a_failing_expectation_fails
|
|||
BOOST_AUTO_TEST_CASE( verifying_all_objects_with_one_of_them_containing_a_failing_expectation_fails )
|
||||
{
|
||||
mock::object o;
|
||||
mock::expectation< void(), silent_error > e;
|
||||
mock::expectation< void() > e;
|
||||
o.set_parent( e );
|
||||
e.expect().once();
|
||||
BOOST_CHECK( ! mock::verify() );
|
||||
|
|
@ -67,7 +57,7 @@ BOOST_AUTO_TEST_CASE( resetting_an_object_containing_a_failing_expectation_and_v
|
|||
BOOST_AUTO_TEST_CASE( an_object_is_assignable_by_sharing_its_state )
|
||||
{
|
||||
mock::object o1;
|
||||
mock::expectation< void(), silent_error > e;
|
||||
mock::expectation< void() > e;
|
||||
{
|
||||
mock::object o2;
|
||||
o2.set_parent( e );
|
||||
|
|
@ -83,7 +73,7 @@ BOOST_AUTO_TEST_CASE( an_object_is_copiable_by_sharing_its_state )
|
|||
{
|
||||
std::auto_ptr< mock::object > o2( new mock::object );
|
||||
const mock::object o1( *o2 );
|
||||
mock::expectation< void(), silent_error > e;
|
||||
mock::expectation< void() > e;
|
||||
o2->set_parent( e );
|
||||
e.expect().once();
|
||||
BOOST_CHECK( ! o2->verify() );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue