Use std::reference_wrapper instead of boost

This commit is contained in:
Alexander Grund 2020-07-09 20:25:40 +02:00
parent 353849e9ad
commit 35e43d58a6
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
16 changed files with 116 additions and 90 deletions

View file

@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE( equal_constraint )
BOOST_CHECK( ! mock::equal( std::string( "string" ) ).c_( "not string" ) );
{
std::string s;
BOOST_AUTO( c, mock::equal( boost::cref( s ) ) );
BOOST_AUTO( c, mock::equal( std::cref( s ) ) );
s = "string";
BOOST_CHECK( c.c_( "string" ) );
}
@ -94,11 +94,7 @@ BOOST_AUTO_TEST_CASE( same_constraint )
int i = 0;
int j = 0;
BOOST_CHECK_EQUAL( i, j );
mock::constraint<
mock::detail::same<
const boost::reference_wrapper< const int >
>
> c = mock::same( boost::cref( i ) );
auto c = mock::same( i );
BOOST_CHECK( ! c.c_( j ) );
BOOST_CHECK( c.c_( i ) );
}
@ -137,9 +133,9 @@ BOOST_AUTO_TEST_CASE( assign_constraint )
int j = 1;
mock::constraint<
mock::detail::assign<
boost::reference_wrapper< const int >
std::reference_wrapper< const int >
>
> c = mock::assign( boost::cref( j ) );
> c = mock::assign( std::cref( j ) );
BOOST_CHECK( c.c_( i ) );
BOOST_CHECK_EQUAL( 1, i );
j = 3;
@ -149,11 +145,7 @@ BOOST_AUTO_TEST_CASE( assign_constraint )
{
int i = 0;
int j = 1;
mock::constraint<
mock::detail::assign<
boost::reference_wrapper< const int >
>
> c = mock::assign( boost::cref( j ) );
auto c = mock::assign( std::cref( j ) );
BOOST_CHECK( c.c_( &i ) );
BOOST_CHECK_EQUAL( 1, i );
j = 3;
@ -164,11 +156,7 @@ BOOST_AUTO_TEST_CASE( assign_constraint )
const int* i = 0;
int k = 1;
int* j = &k;
mock::constraint<
mock::detail::assign<
boost::reference_wrapper< int* const >
>
> c = mock::assign( boost::cref( j ) );
auto c = mock::assign( std::cref( j ) );
BOOST_CHECK( c.c_( i ) );
BOOST_CHECK_EQUAL( j, i );
j = 0;
@ -230,13 +218,13 @@ BOOST_AUTO_TEST_CASE( retrieve_constraint )
{
int i = 0;
const int j = 1;
BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) );
BOOST_CHECK( mock::retrieve( i ).c_( j ) );
BOOST_CHECK_EQUAL( i, j );
}
{
const int* i = 0;
const int j = 1;
BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) );
BOOST_CHECK( mock::retrieve( i ).c_( j ) );
BOOST_CHECK_EQUAL( i, &j );
}
{
@ -332,11 +320,7 @@ BOOST_AUTO_TEST_CASE( contain_constraint_with_const_char_ptr )
BOOST_CHECK( ! mock::contain( "not found" ).c_( std::string( "this is a string" ) ) );
{
const char* s = 0;
mock::constraint<
mock::detail::contain<
boost::reference_wrapper< const char* const >
>
> c = mock::contain( boost::cref( s ) );
auto c = mock::contain( std::cref( s ) );
s = "string";
BOOST_CHECK( c.c_( "this is a string" ) );
BOOST_CHECK( c.c_( std::string( "this is a string" ) ) );
@ -356,9 +340,9 @@ BOOST_AUTO_TEST_CASE( contain_constraint_with_strings )
std::string s;
mock::constraint<
mock::detail::contain<
boost::reference_wrapper< const std::string >
std::reference_wrapper< const std::string >
>
> c = mock::contain( boost::cref( s ) );
> c = mock::contain( std::cref( s ) );
s = "string";
BOOST_CHECK( c.c_( "this is a string" ) );
BOOST_CHECK( c.c_( std::string( "this is a string" ) ) );