File indexing completed on 2025-01-18 09:52:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
0013 #define BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
0014
0015
0016 #include <boost/test/detail/config.hpp>
0017 #include <boost/test/detail/global_typedef.hpp>
0018
0019 #include <boost/test/tree/observer.hpp>
0020 #include <boost/test/tree/fixture.hpp>
0021
0022 #include <boost/test/detail/suppress_warnings.hpp>
0023
0024
0025
0026
0027 namespace boost {
0028 namespace unit_test {
0029
0030
0031
0032
0033
0034 class BOOST_TEST_DECL global_configuration : public test_observer {
0035
0036 public:
0037
0038 global_configuration();
0039
0040
0041
0042
0043 void unregister_from_framework();
0044
0045
0046 ~global_configuration() BOOST_OVERRIDE;
0047
0048
0049 int priority() BOOST_OVERRIDE { return 1; }
0050
0051 private:
0052 bool registered;
0053 };
0054
0055
0056
0057
0058
0059
0060
0061 class BOOST_TEST_DECL global_fixture : public test_unit_fixture {
0062
0063 public:
0064
0065 global_fixture();
0066
0067
0068
0069
0070 void unregister_from_framework();
0071
0072
0073 ~global_fixture() BOOST_OVERRIDE;
0074
0075 private:
0076 bool registered;
0077 };
0078
0079
0080
0081 namespace ut_detail {
0082
0083 template<typename F>
0084 struct global_configuration_impl : public global_configuration {
0085
0086 global_configuration_impl() : m_configuration_observer( 0 ) {
0087 }
0088
0089
0090 void test_start( counter_t, test_unit_id ) BOOST_OVERRIDE {
0091 m_configuration_observer = new F;
0092 }
0093
0094
0095 void test_finish() BOOST_OVERRIDE {
0096 if(m_configuration_observer) {
0097 delete m_configuration_observer;
0098 m_configuration_observer = 0;
0099 }
0100 }
0101 private:
0102
0103 F* m_configuration_observer;
0104 };
0105
0106 template<typename F>
0107 struct global_fixture_impl : public global_fixture {
0108
0109 global_fixture_impl() : m_fixture( 0 ) {
0110 }
0111
0112
0113 void setup() BOOST_OVERRIDE {
0114 m_fixture = new F;
0115 setup_conditional(*m_fixture);
0116 }
0117
0118
0119 void teardown() BOOST_OVERRIDE {
0120 if(m_fixture) {
0121 teardown_conditional(*m_fixture);
0122 }
0123 delete m_fixture;
0124 m_fixture = 0;
0125 }
0126
0127 private:
0128
0129 F* m_fixture;
0130 };
0131
0132 }
0133 }
0134 }
0135
0136 #include <boost/test/detail/enable_warnings.hpp>
0137
0138 #endif
0139