Refactored constraints

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@179 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2011-01-10 22:14:31 +00:00
parent 176611c735
commit 3b6e4f6d37
12 changed files with 204 additions and 454 deletions

View file

@ -337,13 +337,6 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
}
}
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_custom_constraint_calls_unexpected_call_error, error_fixture )
{
mock::function< void( int ) > f;
f.expect().with( mock::constraint( &custom_constraint, "custom constraint" ) );
CHECK_ERROR( f( 42 ), unexpected_call, 0 );
}
/*
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
{
@ -715,24 +708,6 @@ BOOST_FIXTURE_TEST_CASE( expectation_can_be_serialized_to_be_human_readable, err
BOOST_CHECK_EQUAL( expected, to_string( f ) );
f.reset();
}
{
mock::function< void( int ) > f;
f.tag( "my function" );
f.expect().once().with( mock::constraint( &custom_constraint, "custom constraint" ) );
const std::string expected = "my function\n"
". once().with( custom constraint )";
BOOST_CHECK_EQUAL( expected, to_string( f ) );
f.reset();
}
{
mock::function< void( int ) > f;
f.tag( "my function" );
f.expect().once().with( mock::constraint( &custom_constraint, true ) );
const std::string expected = "my function\n"
". once().with( true )";
BOOST_CHECK_EQUAL( expected, to_string( f ) );
f.reset();
}
}
BOOST_FIXTURE_TEST_CASE( expectation_with_remaining_untriggered_matches_upon_destruction_calls_untriggered_expectation, error_fixture )

View file

@ -1,35 +0,0 @@
//
// Copyright Mathieu Champlon 2009
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <turtle/has_operator.hpp>
#include <boost/test/auto_unit_test.hpp>
#define BOOST_LIB_NAME boost_unit_test_framework
#include <boost/config/auto_link.hpp>
namespace
{
struct functor_with_valid_operator
{
bool operator()( float ) const
{
return true;
}
};
BOOST_STATIC_ASSERT(( mock::detail::has_operator< functor_with_valid_operator, float >::type::value ));
struct functor_with_valid_template_operator
{
template< typename T >
bool operator()( T ) const
{
return true;
}
};
BOOST_STATIC_ASSERT(( mock::detail::has_operator< functor_with_valid_template_operator, float >::type::value ));
}

View file

@ -342,7 +342,7 @@ namespace
Expected threshold_;
};
template< typename Expected >
near_constraint< Expected > near( Expected expected, Expected threshold )
mock::constraint< near_constraint< Expected > > near( Expected expected, Expected threshold )
{
return near_constraint< Expected >( expected, threshold );
}