]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/include/boost/test/impl/decorator.ipp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / impl / decorator.ipp
CommitLineData
7c673cae
FG
1// (C) Copyright Gennadiy Rozental 2001.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
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$
9//
10// Version : $Revision$
11//
12// Description : unit test decorators implementation
13// ***************************************************************************
14
15#ifndef BOOST_TEST_TREE_DECORATOR_IPP_091911GER
16#define BOOST_TEST_TREE_DECORATOR_IPP_091911GER
17
18// Boost.Test
19#include <boost/test/tree/decorator.hpp>
20#include <boost/test/tree/test_unit.hpp>
21
22#include <boost/test/framework.hpp>
23#if BOOST_TEST_SUPPORT_TOKEN_ITERATOR
24#include <boost/test/utils/iterator/token_iterator.hpp>
25#endif
26
27#include <boost/test/detail/throw_exception.hpp>
28
29#include <boost/test/detail/suppress_warnings.hpp>
30
31//____________________________________________________________________________//
32
33namespace boost {
34namespace unit_test {
35namespace decorator {
36
37// ************************************************************************** //
38// ************** decorator::collector ************** //
39// ************************************************************************** //
40
41collector&
42collector::operator*( base const& d )
43{
44 m_tu_decorators.push_back( d.clone() );
45
46 return *this;
47}
48
49//____________________________________________________________________________//
50
51void
52collector::store_in( test_unit& tu )
53{
54 tu.p_decorators.value.insert( tu.p_decorators.value.end(), m_tu_decorators.begin(), m_tu_decorators.end() );
55}
56
57//____________________________________________________________________________//
58
59void
60collector::reset()
61{
62 m_tu_decorators.clear();
63}
64
65//____________________________________________________________________________//
66
67// ************************************************************************** //
68// ************** decorator::base ************** //
69// ************************************************************************** //
70
71collector&
72base::operator*() const
73{
74 return collector::instance() * *this;
75}
76
77// ************************************************************************** //
78// ************** decorator::label ************** //
79// ************************************************************************** //
80
81void
82label::apply( test_unit& tu )
83{
84 tu.add_label( m_label );
85}
86
87//____________________________________________________________________________//
88
89// ************************************************************************** //
90// ************** decorator::expected_failures ************** //
91// ************************************************************************** //
92
93void
94expected_failures::apply( test_unit& tu )
95{
96 tu.increase_exp_fail( m_exp_fail );
97}
98
99//____________________________________________________________________________//
100
101// ************************************************************************** //
102// ************** decorator::timeout ************** //
103// ************************************************************************** //
104
105void
106timeout::apply( test_unit& tu )
107{
108 tu.p_timeout.value = m_timeout;
109}
110
111//____________________________________________________________________________//
112
113// ************************************************************************** //
114// ************** decorator::description ************** //
115// ************************************************************************** //
116
117void
118description::apply( test_unit& tu )
119{
120 tu.p_description.value += m_description;
121}
122
123//____________________________________________________________________________//
124
125// ************************************************************************** //
126// ************** decorator::depends_on ************** //
127// ************************************************************************** //
128
129void
130depends_on::apply( test_unit& tu )
131{
132#if !BOOST_TEST_SUPPORT_TOKEN_ITERATOR
133 BOOST_TEST_SETUP_ASSERT( false, "depends_on decorator is not supported on this platform" );
134#else
135 utils::string_token_iterator tit( m_dependency, (utils::dropped_delimeters = "/", utils::kept_delimeters = utils::dt_none) );
136
137 test_unit* dep = &framework::master_test_suite();
138 while( tit != utils::string_token_iterator() ) {
139 BOOST_TEST_SETUP_ASSERT( dep->p_type == TUT_SUITE, std::string( "incorrect dependency specification " ) + m_dependency );
140
141 test_unit_id next_id = static_cast<test_suite*>(dep)->get( *tit );
142
143 BOOST_TEST_SETUP_ASSERT( next_id != INV_TEST_UNIT_ID,
144 std::string( "incorrect dependency specification " ) + m_dependency );
145
146 dep = &framework::get( next_id, TUT_ANY );
147 ++tit;
148 }
149
150 tu.depends_on( dep );
151#endif
152}
153
154//____________________________________________________________________________//
155
156// ************************************************************************** //
157// ************** decorator::enable_if/enabled/disabled ************** //
158// ************************************************************************** //
159
160void
161enable_if_impl::apply_impl( test_unit& tu, bool condition )
162{
163 BOOST_TEST_SETUP_ASSERT(tu.p_default_status == test_unit::RS_INHERIT,
164 "Can't apply multiple enabled/disabled decorators "
165 "to the same test unit " + tu.full_name());
166
167 tu.p_default_status.value = condition ? test_unit::RS_ENABLED : test_unit::RS_DISABLED;
168}
169
170//____________________________________________________________________________//
171
172// ************************************************************************** //
173// ************** decorator::fixture ************** //
174// ************************************************************************** //
175
176void
177fixture_t::apply( test_unit& tu )
178{
179 tu.p_fixtures.value.push_back( m_impl );
180}
181
182//____________________________________________________________________________//
183
184// ************************************************************************** //
185// ************** decorator::depends_on ************** //
186// ************************************************************************** //
187
188void
189precondition::apply( test_unit& tu )
190{
191 tu.add_precondition( m_precondition );
192}
193
194//____________________________________________________________________________//
195
196} // namespace decorator
197} // namespace unit_test
198} // namespace boost
199
200#include <boost/test/detail/enable_warnings.hpp>
201
202#endif // BOOST_TEST_TREE_DECORATOR_IPP_091911GER