mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Fixed regression
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@665 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
24530c4e3c
commit
c697b48802
7 changed files with 76 additions and 24 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\test\mock_error.hpp" />
|
<ClInclude Include="..\..\test\mock_error.hpp" />
|
||||||
|
<ClInclude Include="..\..\test\undefined.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
||||||
|
|
@ -36,6 +37,7 @@
|
||||||
<ClCompile Include="..\..\test\test_mock.cpp" />
|
<ClCompile Include="..\..\test\test_mock.cpp" />
|
||||||
<ClCompile Include="..\..\test\test_object.cpp" />
|
<ClCompile Include="..\..\test\test_object.cpp" />
|
||||||
<ClCompile Include="..\..\test\test_sequence.cpp" />
|
<ClCompile Include="..\..\test\test_sequence.cpp" />
|
||||||
|
<ClCompile Include="..\..\test\undefined.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{74810A2A-33D8-47D6-9A50-71261F1683F5}</ProjectGuid>
|
<ProjectGuid>{74810A2A-33D8-47D6-9A50-71261F1683F5}</ProjectGuid>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
<ClInclude Include="..\..\test\mock_error.hpp">
|
<ClInclude Include="..\..\test\mock_error.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\test\undefined.hpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\test\test_constraints.cpp">
|
<ClCompile Include="..\..\test\test_constraints.cpp">
|
||||||
|
|
@ -57,5 +60,8 @@
|
||||||
<ClCompile Include="..\..\test\test_matcher.cpp">
|
<ClCompile Include="..\..\test\test_matcher.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\test\undefined.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include "../mock_error.hpp"
|
#include "../mock_error.hpp"
|
||||||
|
#include "../undefined.hpp"
|
||||||
#include <turtle/detail/function.hpp>
|
#include <turtle/detail/function.hpp>
|
||||||
#include <turtle/constraints.hpp>
|
#include <turtle/constraints.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
|
|
@ -533,6 +534,20 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
|
||||||
BOOST_CHECK_NO_THROW( f() );
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_shared_ptr_value, error_fixture )
|
||||||
|
{
|
||||||
|
{
|
||||||
|
mock::detail::function< boost::shared_ptr< A >() > f;
|
||||||
|
f.expect().returns( new B );
|
||||||
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
|
CHECK_CALLS( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_by_reference, error_fixture )
|
||||||
|
{
|
||||||
{
|
{
|
||||||
mock::detail::function< A&() > f;
|
mock::detail::function< A&() > f;
|
||||||
B b;
|
B b;
|
||||||
|
|
@ -547,6 +562,11 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
|
||||||
BOOST_CHECK_NO_THROW( f() );
|
BOOST_CHECK_NO_THROW( f() );
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
mock::detail::function< undefined&() > f;
|
||||||
|
f.expect().returns( boost::ref( get_undefined() ) );
|
||||||
|
f.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "mock_error.hpp"
|
#include "mock_error.hpp"
|
||||||
|
#include "undefined.hpp"
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
@ -128,17 +129,15 @@ BOOST_AUTO_TEST_CASE( mock_object_method_const_disambiguation )
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct my_declared_but_undefined_type;
|
MOCK_CLASS( my_undefined_mock )
|
||||||
|
|
||||||
MOCK_CLASS( my_declared_but_undefined_mock )
|
|
||||||
{
|
{
|
||||||
MOCK_METHOD_EXT( m, 1, void( my_declared_but_undefined_type& ), t )
|
MOCK_METHOD_EXT( m, 1, void( undefined& ), t )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( mock_object_method_with_declared_but_not_defined_parameter_is_valid )
|
BOOST_AUTO_TEST_CASE( mock_object_method_with_declared_but_not_defined_parameter_is_valid )
|
||||||
{
|
{
|
||||||
my_declared_but_undefined_mock mock;
|
my_undefined_mock mock;
|
||||||
MOCK_EXPECT( mock.t );
|
MOCK_EXPECT( mock.t );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
18
test/undefined.cpp
Normal file
18
test/undefined.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
// http://turtle.sourceforge.net
|
||||||
|
//
|
||||||
|
// Copyright Mathieu Champlon 2013
|
||||||
|
//
|
||||||
|
// 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 "undefined.hpp"
|
||||||
|
|
||||||
|
struct undefined
|
||||||
|
{};
|
||||||
|
|
||||||
|
undefined& get_undefined()
|
||||||
|
{
|
||||||
|
static undefined u;
|
||||||
|
return u;
|
||||||
|
}
|
||||||
16
test/undefined.hpp
Normal file
16
test/undefined.hpp
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// http://turtle.sourceforge.net
|
||||||
|
//
|
||||||
|
// Copyright Mathieu Champlon 2013
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
#ifndef MOCK_TEST_UNDEFINED_HPP_INCLUDED
|
||||||
|
#define MOCK_TEST_UNDEFINED_HPP_INCLUDED
|
||||||
|
|
||||||
|
struct undefined;
|
||||||
|
|
||||||
|
undefined& get_undefined();
|
||||||
|
|
||||||
|
#endif // MOCK_TEST_UNDEFINED_HPP_INCLUDED
|
||||||
|
|
@ -12,9 +12,7 @@
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "lambda.hpp"
|
#include "lambda.hpp"
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
|
|
@ -37,26 +35,19 @@ namespace detail
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
void returns( Value v,
|
void returns( Value v )
|
||||||
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
{
|
||||||
boost::is_convertible< Value, result_type > >::type* = 0 )
|
r_ = boost::make_shared< Value >( v );
|
||||||
|
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
||||||
|
}
|
||||||
|
template< typename Value >
|
||||||
|
void returns( Value* v )
|
||||||
{
|
{
|
||||||
r_ = boost::make_shared< result_type >( v );
|
r_ = boost::make_shared< result_type >( v );
|
||||||
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
||||||
}
|
}
|
||||||
template< typename Value >
|
|
||||||
void returns( Value v,
|
|
||||||
BOOST_DEDUCED_TYPENAME boost::disable_if<
|
|
||||||
boost::is_convertible< Value, result_type > >::type* = 0 )
|
|
||||||
{
|
|
||||||
// if an error is generated by the line below it means a value
|
|
||||||
// passed to 'returns' was of the wrong type as it cannot be
|
|
||||||
// used to copy construct a Result
|
|
||||||
r_ = boost::make_shared< Value >( v );
|
|
||||||
f_ = lambda_type::make_val( boost::ref( *r_ ) );
|
|
||||||
}
|
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( boost::reference_wrapper< Y > r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_val( r );
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +89,7 @@ namespace detail
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_val( r );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( boost::reference_wrapper< Y > r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_val( r );
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +202,7 @@ namespace detail
|
||||||
f_ = lambda_type::make_val( boost::ref( r_ ) );
|
f_ = lambda_type::make_val( boost::ref( r_ ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void set( boost::reference_wrapper< Y > r )
|
void set( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
f_ = lambda_type::make_val( r );
|
f_ = lambda_type::make_val( r );
|
||||||
r_.reset();
|
r_.reset();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue