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)
6 // See http://www.boost.org/libs/test for the library home page.
9 //!@brief some trivial global typedefs
10 // ***************************************************************************
12 #ifndef BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
13 #define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
15 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
17 #define BOOST_TEST_L( s ) ::boost::unit_test::const_string( s, sizeof( s ) - 1 )
18 #define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) )
19 #define BOOST_TEST_EMPTY_STRING BOOST_TEST_L( "" )
21 #include <boost/test/detail/suppress_warnings.hpp>
23 //____________________________________________________________________________//
28 typedef unsigned long counter_t;
30 //____________________________________________________________________________//
32 enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
34 //____________________________________________________________________________//
36 //! Indicates the output format for the loggers or the test tree printing
37 enum output_format { OF_INVALID,
38 OF_CLF, ///< compiler log format
39 OF_XML, ///< XML format for report and log,
40 OF_JUNIT, ///< JUNIT format for report and log,
41 OF_CUSTOM_LOGGER, ///< User specified logger.
42 OF_DOT ///< dot format for output content
45 //____________________________________________________________________________//
47 enum test_unit_type { TUT_CASE = 0x01, TUT_SUITE = 0x10, TUT_ANY = 0x11 };
49 //____________________________________________________________________________//
51 enum assertion_result { AR_FAILED, AR_PASSED, AR_TRIGGERED };
53 //____________________________________________________________________________//
55 typedef unsigned long test_unit_id;
57 const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF;
58 const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE;
59 const test_unit_id MIN_TEST_CASE_ID = 0x00010000;
60 const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00;
61 const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
63 //____________________________________________________________________________//
68 test_id_2_unit_type( test_unit_id id )
70 return (id & 0xFFFF0000) != 0 ? TUT_CASE : TUT_SUITE;
73 //! Helper class for restoring the current test unit ID in a RAII manner
74 struct test_unit_id_restore {
75 test_unit_id_restore(test_unit_id& to_restore_, test_unit_id new_value)
76 : to_restore(to_restore_)
78 to_restore = new_value;
80 ~test_unit_id_restore() {
84 test_unit_id& to_restore;
88 //____________________________________________________________________________//
90 } // namespace ut_detail
92 // helper templates to prevent ODR violations
94 struct static_constant {
99 T static_constant<T>::value;
101 //____________________________________________________________________________//
103 // helper defines for singletons.
104 // BOOST_TEST_SINGLETON_CONS should appear in the class body,
105 // BOOST_TEST_SINGLETON_CONS_IMPL should be in only one translation unit. The
106 // global instance should be declared by BOOST_TEST_SINGLETON_INST.
108 #define BOOST_TEST_SINGLETON_CONS_NO_CTOR( type ) \
110 static type& instance(); \
112 BOOST_DELETED_FUNCTION(type(type const&)) \
113 BOOST_DELETED_FUNCTION(type& operator=(type const&)) \
114 BOOST_DEFAULTED_FUNCTION(~type(), {}) \
117 #define BOOST_TEST_SINGLETON_CONS( type ) \
118 BOOST_TEST_SINGLETON_CONS_NO_CTOR(type) \
120 BOOST_DEFAULTED_FUNCTION(type(), {}) \
123 #define BOOST_TEST_SINGLETON_CONS_IMPL( type ) \
124 type& type::instance() { \
125 static type the_inst; return the_inst; \
129 //____________________________________________________________________________//
131 #if defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
132 #define BOOST_TEST_SINGLETON_INST( inst ) \
133 static BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN (inst, _t)::instance();
137 #define BOOST_TEST_SINGLETON_INST( inst ) \
138 namespace { BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN( inst, _t)::instance(); }
142 } // namespace unit_test
145 //____________________________________________________________________________//
147 #include <boost/test/detail/enable_warnings.hpp>
149 #endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER