mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Initial import
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@2 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
8081e7006f
commit
8e18676b92
31 changed files with 4062 additions and 0 deletions
78
src/tests/turtle_test/sequence_test.cpp
Normal file
78
src/tests/turtle_test/sequence_test.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// Copyright Mathieu Champlon 2008
|
||||
//
|
||||
// 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/sequence.hpp>
|
||||
#include <turtle/expectation.hpp>
|
||||
#include <turtle/constraint.hpp>
|
||||
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#define BOOST_LIB_NAME boost_unit_test_framework
|
||||
#include <boost/config/auto_link.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_throws )
|
||||
{
|
||||
mock::sequence s;
|
||||
mock::expectation< void( int ) > e;
|
||||
e.expect().once().with( 1 ).in( s );
|
||||
e.expect().once().with( 2 ).in( s );
|
||||
BOOST_CHECK_NO_THROW( e( 2 ) );
|
||||
BOOST_CHECK_THROW( e( 1 ), mock::exception );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_out_of_order_multiple_invocations_throws )
|
||||
{
|
||||
mock::sequence s;
|
||||
mock::expectation< void( int ) > e;
|
||||
e.expect().with( 1 ).in( s );
|
||||
e.expect().once().with( 2 ).in( s );
|
||||
BOOST_CHECK_NO_THROW( e( 1 ) );
|
||||
BOOST_CHECK_NO_THROW( e( 2 ) );
|
||||
BOOST_CHECK_THROW( e( 1 ), mock::exception );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_and_calling_in_order_is_valid )
|
||||
{
|
||||
mock::sequence s;
|
||||
mock::expectation< void( int ) > e;
|
||||
e.expect().once().with( 1 ).in( s );
|
||||
e.expect().once().with( 2 ).in( s );
|
||||
BOOST_CHECK_NO_THROW( e( 1 ) );
|
||||
BOOST_CHECK_NO_THROW( e( 2 ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( registering_to_a_sequence_enforces_call_order_verification_between_two_different_expectations )
|
||||
{
|
||||
mock::sequence s;
|
||||
mock::expectation< void() > e1, e2;
|
||||
e1.expect().once().in( s );
|
||||
e2.expect().once().in( s );
|
||||
BOOST_CHECK_NO_THROW( e2() );
|
||||
BOOST_CHECK_THROW( e1(), mock::exception );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( destroying_a_sequence_removes_order_call_enforcement )
|
||||
{
|
||||
mock::expectation< void() > e1, e2;
|
||||
{
|
||||
mock::sequence s;
|
||||
e1.expect().once().in( s );
|
||||
e2.expect().once().in( s );
|
||||
}
|
||||
BOOST_CHECK_NO_THROW( e2() );
|
||||
BOOST_CHECK_NO_THROW( e1() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( resetting_an_expectation_removes_it_from_order_call_enforcement )
|
||||
{
|
||||
mock::sequence s;
|
||||
mock::expectation< void() > e1, e2;
|
||||
e1.expect().once().in( s );
|
||||
e2.expect().once().in( s );
|
||||
e1.reset();
|
||||
BOOST_CHECK_NO_THROW( e2() );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue