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:
mat007 2013-05-21 09:21:52 +00:00
parent 24530c4e3c
commit c697b48802
7 changed files with 76 additions and 24 deletions

View file

@ -8,6 +8,7 @@
#define BOOST_AUTO_TEST_MAIN
#include "../mock_error.hpp"
#include "../undefined.hpp"
#include <turtle/detail/function.hpp>
#include <turtle/constraints.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() );
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;
B b;
@ -547,6 +562,11 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_valu
BOOST_CHECK_NO_THROW( f() );
CHECK_CALLS( 1 );
}
{
mock::detail::function< undefined&() > f;
f.expect().returns( boost::ref( get_undefined() ) );
f.reset();
}
}
namespace

View file

@ -7,6 +7,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include "mock_error.hpp"
#include "undefined.hpp"
#include <turtle/mock.hpp>
#include <boost/test/auto_unit_test.hpp>
#include <boost/noncopyable.hpp>
@ -128,17 +129,15 @@ BOOST_AUTO_TEST_CASE( mock_object_method_const_disambiguation )
namespace
{
struct my_declared_but_undefined_type;
MOCK_CLASS( my_declared_but_undefined_mock )
MOCK_CLASS( my_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 )
{
my_declared_but_undefined_mock mock;
my_undefined_mock mock;
MOCK_EXPECT( mock.t );
}

18
test/undefined.cpp Normal file
View 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
View 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