mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added tests for mock::detail::check
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@544 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
cc0a24a939
commit
77a99b8893
4 changed files with 39 additions and 3 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
<ClInclude Include="..\..\test\mock_error.hpp" />
|
<ClInclude Include="..\..\test\mock_error.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\test\detail\test_check.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
<ClCompile Include="..\..\test\detail\test_function.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_invocation.cpp" />
|
<ClCompile Include="..\..\test\detail\test_invocation.cpp" />
|
||||||
<ClCompile Include="..\..\test\detail\test_is_functor.cpp" />
|
<ClCompile Include="..\..\test\detail\test_is_functor.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -54,5 +54,8 @@
|
||||||
<ClCompile Include="..\..\test\detail\test_is_functor.cpp">
|
<ClCompile Include="..\..\test\detail\test_is_functor.cpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\test\detail\test_check.cpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
32
test/detail/test_check.cpp
Normal file
32
test/detail/test_check.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
// http://turtle.sourceforge.net
|
||||||
|
//
|
||||||
|
// Copyright Mathieu Champlon 2012
|
||||||
|
//
|
||||||
|
// 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/detail/check.hpp>
|
||||||
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template< typename Expected, typename Actual >
|
||||||
|
bool check( Expected expected, Actual actual )
|
||||||
|
{
|
||||||
|
return mock::detail::check< Expected, Actual >( expected )( actual );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( int_and_int_can_be_compared )
|
||||||
|
{
|
||||||
|
BOOST_CHECK( check( 3, 3 ) );
|
||||||
|
BOOST_CHECK( ! check( 3, 4 ) );
|
||||||
|
BOOST_CHECK( ! check( 4, 3 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( ref_to_int_and_int_can_be_compared )
|
||||||
|
{
|
||||||
|
BOOST_CHECK( check< int >( boost::cref( 3 ), 3 ) );
|
||||||
|
BOOST_CHECK( ! check< int >( boost::cref( 3 ), 4 ) );
|
||||||
|
}
|
||||||
|
|
@ -44,11 +44,11 @@ namespace detail
|
||||||
explicit check( Expected expected )
|
explicit check( Expected expected )
|
||||||
: expected_( expected )
|
: expected_( expected )
|
||||||
{}
|
{}
|
||||||
private:
|
|
||||||
virtual bool operator()( Actual actual )
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return actual == boost::unwrap_ref( expected_ );
|
return actual == boost::unwrap_ref( expected_ );
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << mock::format( expected_ );
|
s << mock::format( expected_ );
|
||||||
|
|
@ -65,11 +65,11 @@ namespace detail
|
||||||
explicit check( const constraint< Constraint >& c )
|
explicit check( const constraint< Constraint >& c )
|
||||||
: c_( c.f_ )
|
: c_( c.f_ )
|
||||||
{}
|
{}
|
||||||
private:
|
|
||||||
virtual bool operator()( Actual actual )
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return c_( actual );
|
return c_( actual );
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << mock::format( c_ );
|
s << mock::format( c_ );
|
||||||
|
|
@ -89,11 +89,11 @@ namespace detail
|
||||||
explicit check( const Functor& f )
|
explicit check( const Functor& f )
|
||||||
: f_( f )
|
: f_( f )
|
||||||
{}
|
{}
|
||||||
private:
|
|
||||||
virtual bool operator()( Actual actual )
|
virtual bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return f_( actual );
|
return f_( actual );
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << mock::format( f_ );
|
s << mock::format( f_ );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue