blob: 7c96d34e8986b49701afd5f338c613d0af8e4799 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// (C) Copyright Gennadiy Rozental 2001.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//
/// @file
/// Defines global_fixture
// ***************************************************************************
#ifndef BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
#define BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
// Boost.Test
#include <boost/test/detail/config.hpp>
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/tree/observer.hpp>
#include <boost/test/tree/fixture.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
namespace boost {
namespace unit_test {
// ************************************************************************** //
// ************** global_configuration ************** //
// ************************************************************************** //
class BOOST_TEST_DECL global_configuration : public test_observer {
public:
// Constructor
global_configuration();
// Dtor
virtual ~global_configuration();
// Happens after the framework global observer init has been done
virtual int priority() { return 1; }
};
// ************************************************************************** //
// ************** global_fixture ************** //
// ************************************************************************** //
class BOOST_TEST_DECL global_fixture : public test_unit_fixture {
public:
// Constructor
global_fixture();
// Dtor
virtual ~global_fixture();
};
//____________________________________________________________________________//
namespace ut_detail {
template<typename F>
struct global_configuration_impl : public global_configuration {
// Constructor
global_configuration_impl() : m_configuration_observer( 0 ) {
}
// test observer interface
virtual void test_start( counter_t ) {
m_configuration_observer = new F;
}
// test observer interface
virtual void test_finish() {
if(m_configuration_observer) {
delete m_configuration_observer;
m_configuration_observer = 0;
}
}
private:
// Data members
F* m_configuration_observer;
};
template<typename F>
struct global_fixture_impl : public global_fixture {
// Constructor
global_fixture_impl() : m_fixture( 0 ) {
}
// test fixture interface
virtual void setup() {
m_fixture = new F;
setup_conditional(*m_fixture);
}
// test fixture interface
virtual void teardown() {
if(m_fixture) {
teardown_conditional(*m_fixture);
}
delete m_fixture;
m_fixture = 0;
}
private:
// Data members
F* m_fixture;
};
} // namespace ut_detail
} // namespace unit_test
} // namespace boost
#include <boost/test/detail/enable_warnings.hpp>
#endif // BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
|