31
|
1 |
// (C) Copyright Gennadiy Rozental 2005.
|
|
2 |
// Use, modification, and distribution are subject to the
|
|
3 |
// Boost Software License, Version 1.0. (See accompanying file
|
|
4 |
// http://www.boost.org/LICENSE_1_0.txt)
|
|
5 |
|
|
6 |
// See http://www.boost.org/libs/test for the library home page.
|
|
7 |
//
|
|
8 |
// File : $RCSfile: interaction_based.ipp,v $
|
|
9 |
//
|
|
10 |
// Version : $Revision: 1.7 $
|
|
11 |
//
|
|
12 |
// Description : Facilities to perform interaction-based testing
|
|
13 |
// ***************************************************************************
|
|
14 |
/*
|
|
15 |
* © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef BOOST_TEST_INTERACTION_BASED_IPP_112105GER
|
|
19 |
#define BOOST_TEST_INTERACTION_BASED_IPP_112105GER
|
|
20 |
|
|
21 |
// Boost.Test
|
|
22 |
#include <boost/test/detail/config.hpp>
|
|
23 |
|
|
24 |
#ifndef __SYMBIAN32__
|
|
25 |
#if !BOOST_WORKAROUND(__GNUC__, < 3) && \
|
|
26 |
!BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
|
27 |
!BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
|
|
28 |
!BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
|
|
29 |
#endif
|
|
30 |
// Boost.Test
|
|
31 |
#include <boost/test/detail/config.hpp>
|
|
32 |
#include <boost/test/utils/callback.hpp>
|
|
33 |
#include <boost/test/interaction_based.hpp>
|
|
34 |
#include <boost/test/mock_object.hpp>
|
|
35 |
#include <boost/test/framework.hpp> // for setup_error
|
|
36 |
|
|
37 |
#include <boost/test/detail/suppress_warnings.hpp>
|
|
38 |
|
|
39 |
// STL
|
|
40 |
#include <stdexcept>
|
|
41 |
#include <string>
|
|
42 |
|
|
43 |
//____________________________________________________________________________//
|
|
44 |
|
|
45 |
namespace boost {
|
|
46 |
|
|
47 |
namespace itest { // interaction-based testing
|
|
48 |
|
|
49 |
// ************************************************************************** //
|
|
50 |
// ************** manager ************** //
|
|
51 |
// ************************************************************************** //
|
|
52 |
|
|
53 |
manager::manager()
|
|
54 |
{
|
|
55 |
instance_ptr( true, this );
|
|
56 |
}
|
|
57 |
|
|
58 |
//____________________________________________________________________________//
|
|
59 |
|
|
60 |
manager::~manager()
|
|
61 |
{
|
|
62 |
instance_ptr( true );
|
|
63 |
}
|
|
64 |
|
|
65 |
//____________________________________________________________________________//
|
|
66 |
|
|
67 |
manager*
|
|
68 |
manager::instance_ptr( bool reset, manager* new_ptr )
|
|
69 |
{
|
|
70 |
static manager dummy( 0 );
|
|
71 |
|
|
72 |
static manager* ptr = &dummy;
|
|
73 |
|
|
74 |
if( reset ) {
|
|
75 |
if( new_ptr ) {
|
|
76 |
if( ptr != &dummy )
|
|
77 |
throw unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) );
|
|
78 |
|
|
79 |
ptr = new_ptr;
|
|
80 |
}
|
|
81 |
else
|
|
82 |
ptr = &dummy;
|
|
83 |
}
|
|
84 |
|
|
85 |
return ptr;
|
|
86 |
}
|
|
87 |
|
|
88 |
} // namespace itest
|
|
89 |
|
|
90 |
} // namespace boost
|
|
91 |
|
|
92 |
//____________________________________________________________________________//
|
|
93 |
|
|
94 |
#include <boost/test/detail/enable_warnings.hpp>
|
|
95 |
|
|
96 |
#endif // not ancient compiler
|
|
97 |
|
|
98 |
// ***************************************************************************
|
|
99 |
// Revision History :
|
|
100 |
//
|
|
101 |
// $Log: interaction_based.ipp,v $
|
|
102 |
// Revision 1.7 2006/03/19 07:27:52 rogeeff
|
|
103 |
// streamline test setup error message
|
|
104 |
//
|
|
105 |
// Revision 1.6 2006/02/23 15:10:00 rogeeff
|
|
106 |
// vc70 out
|
|
107 |
//
|
|
108 |
// Revision 1.5 2006/02/22 16:13:34 rogeeff
|
|
109 |
// ifdef out for non supported compilers
|
|
110 |
//
|
|
111 |
// Revision 1.4 2006/01/28 08:52:35 rogeeff
|
|
112 |
// operator new overloads made inline to:
|
|
113 |
// 1. prevent issues with export them from DLL
|
|
114 |
// 2. release link issue fixed
|
|
115 |
//
|
|
116 |
// Revision 1.3 2006/01/15 11:14:39 rogeeff
|
|
117 |
// simpl_mock -> mock_object<>::prototype()
|
|
118 |
// operator new need to be rethinked
|
|
119 |
//
|
|
120 |
// Revision 1.2 2005/12/22 15:49:32 rogeeff
|
|
121 |
// sunpro port
|
|
122 |
// made operator new conformant
|
|
123 |
//
|
|
124 |
// Revision 1.1 2005/12/14 05:56:56 rogeeff
|
|
125 |
// Interraction based / logged expectation testing is introduced
|
|
126 |
//
|
|
127 |
// ***************************************************************************
|
|
128 |
#ifndef __SYMBIAN32__
|
|
129 |
#endif // BOOST_TEST_INTERACTION_BASED_IPP_112105GER
|
|
130 |
#endif
|