mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added thread-safety
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@730 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
f1580c95cc
commit
086a42e432
15 changed files with 464 additions and 12 deletions
|
|
@ -846,3 +846,33 @@ BOOST_FIXTURE_TEST_CASE( adding_file_and_line_number_information, mock_error_fix
|
|||
BOOST_CHECK_EQUAL( "file name", mock_error_data.last_file );
|
||||
BOOST_CHECK_EQUAL( 42, mock_error_data.last_line );
|
||||
}
|
||||
|
||||
#ifdef MOCK_THREAD_SAFE
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
void iterate( mock::detail::function< int() >& f )
|
||||
{
|
||||
f.expect().once().returns( 0 );
|
||||
try
|
||||
{
|
||||
f();
|
||||
}
|
||||
catch( ... )
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE( function_is_thread_safe, mock_error_fixture )
|
||||
{
|
||||
mock::detail::function< int() > f;
|
||||
boost::thread_group group;
|
||||
for( int i = 0; i < 100; ++i )
|
||||
group.create_thread( boost::bind( &iterate, boost::ref( f ) ) );
|
||||
group.join_all();
|
||||
CHECK_CALLS( 100 );
|
||||
}
|
||||
|
||||
#endif // MOCK_THREAD_SAFE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue