Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:41

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// Defines global_fixture
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
0013 #define BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
0014 
0015 // Boost.Test
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 // **************             global_configuration             ************** //
0032 // ************************************************************************** //
0033 
0034 class BOOST_TEST_DECL global_configuration : public test_observer {
0035 
0036 public:
0037     // Constructor
0038     global_configuration();
0039 
0040     /// Unregisters the global fixture from the framework
0041     ///
0042     /// This is called by the framework at shutdown time
0043     void unregister_from_framework();
0044 
0045     // Dtor
0046     ~global_configuration() BOOST_OVERRIDE;
0047 
0048     // Happens after the framework global observer init has been done
0049     int     priority() BOOST_OVERRIDE { return 1; }
0050 
0051 private:
0052     bool registered;
0053 };
0054 
0055 
0056 
0057 // ************************************************************************** //
0058 // **************                global_fixture                ************** //
0059 // ************************************************************************** //
0060 
0061 class BOOST_TEST_DECL global_fixture : public test_unit_fixture {
0062 
0063 public:
0064     // Constructor
0065     global_fixture();
0066 
0067     /// Unregisters the global fixture from the framework
0068     ///
0069     /// This is called by the framework at shutdown time
0070     void unregister_from_framework();
0071 
0072     // Dtor
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     // Constructor
0086     global_configuration_impl() : m_configuration_observer( 0 )  {
0087     }
0088 
0089     // test observer interface
0090     void    test_start( counter_t, test_unit_id ) BOOST_OVERRIDE {
0091         m_configuration_observer = new F;
0092     }
0093 
0094     // test observer interface
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     // Data members
0103     F*  m_configuration_observer;
0104 };
0105 
0106 template<typename F>
0107 struct global_fixture_impl : public global_fixture {
0108     // Constructor
0109     global_fixture_impl() : m_fixture( 0 )  {
0110     }
0111 
0112     // test fixture interface
0113     void setup() BOOST_OVERRIDE                    {
0114         m_fixture = new F;
0115         setup_conditional(*m_fixture);
0116     }
0117 
0118     // test fixture interface
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     // Data members
0129     F*  m_fixture;
0130 };
0131 
0132 } // namespace ut_detail
0133 } // namespace unit_test
0134 } // namespace boost
0135 
0136 #include <boost/test/detail/enable_warnings.hpp>
0137 
0138 #endif // BOOST_TEST_TREE_GLOBAL_FIXTURE_HPP_091911GER
0139