Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/test/detail/global_typedef.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 //!@brief some trivial global typedefs
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
0013 #define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
0014 
0015 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
0016 
0017 #define BOOST_TEST_L( s )         ::boost::unit_test::const_string( s, sizeof( s ) - 1 )
0018 #define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) )
0019 #define BOOST_TEST_EMPTY_STRING   BOOST_TEST_L( "" )
0020 
0021 #include <boost/test/detail/suppress_warnings.hpp>
0022 
0023 //____________________________________________________________________________//
0024 
0025 namespace boost {
0026 namespace unit_test {
0027 
0028 typedef unsigned long   counter_t;
0029 
0030 //____________________________________________________________________________//
0031 
0032 enum BOOST_SYMBOL_VISIBLE report_level  { INV_REPORT_LEVEL,
0033                                           CONFIRMATION_REPORT,
0034                                           SHORT_REPORT,
0035                                           DETAILED_REPORT,
0036                                           NO_REPORT };
0037 
0038 //____________________________________________________________________________//
0039 
0040 //! Indicates the output format for the loggers or the test tree printing
0041 enum BOOST_SYMBOL_VISIBLE output_format { OF_INVALID,
0042                                           OF_CLF,      ///< compiler log format
0043                                           OF_XML,      ///< XML format for report and log,
0044                                           OF_JUNIT,    ///< JUNIT format for report and log,
0045                                           OF_CUSTOM_LOGGER, ///< User specified logger.
0046                                           OF_DOT       ///< dot format for output content
0047 };
0048 
0049 //____________________________________________________________________________//
0050 
0051 enum test_unit_type { TUT_CASE = 0x01, TUT_SUITE = 0x10, TUT_ANY = 0x11 };
0052 
0053 //____________________________________________________________________________//
0054 
0055 enum assertion_result { AR_FAILED, AR_PASSED, AR_TRIGGERED };
0056 
0057 //____________________________________________________________________________//
0058 
0059 typedef unsigned long   test_unit_id;
0060 
0061 const test_unit_id INV_TEST_UNIT_ID  = 0xFFFFFFFF;
0062 const test_unit_id MAX_TEST_CASE_ID  = 0xFFFFFFFE;
0063 const test_unit_id MIN_TEST_CASE_ID  = 0x00010000;
0064 const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00;
0065 const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
0066 
0067 //____________________________________________________________________________//
0068 
0069 namespace ut_detail {
0070 
0071 inline test_unit_type
0072 test_id_2_unit_type( test_unit_id id )
0073 {
0074     return (id & 0xFFFF0000) != 0 ? TUT_CASE : TUT_SUITE;
0075 }
0076 
0077 //! Helper class for restoring the current test unit ID in a RAII manner
0078 struct test_unit_id_restore {
0079     test_unit_id_restore(test_unit_id& to_restore_, test_unit_id new_value)
0080     : to_restore(to_restore_)
0081     , bkup(to_restore_) {
0082         to_restore = new_value;
0083     }
0084     ~test_unit_id_restore() {
0085         to_restore = bkup;
0086     }
0087 private:
0088     test_unit_id& to_restore;
0089     test_unit_id bkup;
0090 };
0091 
0092 //____________________________________________________________________________//
0093 
0094 } // namespace ut_detail
0095 
0096 // helper templates to prevent ODR violations
0097 template<class T>
0098 struct static_constant {
0099     static T value;
0100 };
0101 
0102 template<class T>
0103 T static_constant<T>::value;
0104 
0105 //____________________________________________________________________________//
0106 
0107 // helper defines for singletons.
0108 // BOOST_TEST_SINGLETON_CONS should appear in the class body,
0109 // BOOST_TEST_SINGLETON_CONS_IMPL should be in only one translation unit. The
0110 // global instance should be declared by BOOST_TEST_SINGLETON_INST.
0111 
0112 #define BOOST_TEST_SINGLETON_CONS_NO_CTOR( type )       \
0113 public:                                                 \
0114   static type& instance();                              \
0115 private:                                                \
0116   BOOST_DELETED_FUNCTION(type(type const&))             \
0117   BOOST_DELETED_FUNCTION(type& operator=(type const&))  \
0118   BOOST_DEFAULTED_FUNCTION(~type(), {})                 \
0119 /**/
0120 
0121 #define BOOST_TEST_SINGLETON_CONS( type )               \
0122   BOOST_TEST_SINGLETON_CONS_NO_CTOR(type)               \
0123 private:                                                \
0124   BOOST_DEFAULTED_FUNCTION(type(), {})                  \
0125 /**/
0126 
0127 #define BOOST_TEST_SINGLETON_CONS_IMPL( type )          \
0128   type& type::instance() {                              \
0129     static type the_inst; return the_inst;              \
0130   }                                                     \
0131 /**/
0132 
0133 //____________________________________________________________________________//
0134 
0135 #if defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
0136 #define BOOST_TEST_SINGLETON_INST( inst ) \
0137 static BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN (inst, _t)::instance();
0138 
0139 #else
0140 
0141 #define BOOST_TEST_SINGLETON_INST( inst ) \
0142 namespace { BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN( inst, _t)::instance(); }
0143 
0144 #endif
0145 
0146 } // namespace unit_test
0147 } // namespace boost
0148 
0149 //____________________________________________________________________________//
0150 
0151 #include <boost/test/detail/enable_warnings.hpp>
0152 
0153 #endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER