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)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8//!@file
9//!@brief some trivial global typedefs
10// ***************************************************************************
11
12#ifndef BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
13#define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
14
15#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
16
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( "" )
20
21#include <boost/test/detail/suppress_warnings.hpp>
22
23//____________________________________________________________________________//
24
25namespace boost {
26namespace unit_test {
27
28typedef unsigned long counter_t;
29
30//____________________________________________________________________________//
31
32enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
33
34//____________________________________________________________________________//
35
36//! Indicates the output format for the loggers or the test tree printing
37enum 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
43};
44
45//____________________________________________________________________________//
46
47enum test_unit_type { TUT_CASE = 0x01, TUT_SUITE = 0x10, TUT_ANY = 0x11 };
48
49//____________________________________________________________________________//
50
51enum assertion_result { AR_FAILED, AR_PASSED, AR_TRIGGERED };
52
53//____________________________________________________________________________//
54
55typedef unsigned long test_unit_id;
56
57const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF;
58const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE;
59const test_unit_id MIN_TEST_CASE_ID = 0x00010000;
60const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00;
61const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
62
63//____________________________________________________________________________//
64
65namespace ut_detail {
66
67inline test_unit_type
68test_id_2_unit_type( test_unit_id id )
69{
70 return (id & 0xFFFF0000) != 0 ? TUT_CASE : TUT_SUITE;
71}
72
73//! Helper class for restoring the current test unit ID in a RAII manner
74struct test_unit_id_restore {
75 test_unit_id_restore(test_unit_id& to_restore_, test_unit_id new_value)
76 : to_restore(to_restore_)
77 , bkup(to_restore_) {
78 to_restore = new_value;
79 }
80 ~test_unit_id_restore() {
81 to_restore = bkup;
82 }
83private:
84 test_unit_id& to_restore;
85 test_unit_id bkup;
86};
87
88//____________________________________________________________________________//
89
90} // namespace ut_detail
91
92// helper templates to prevent ODR violations
93template<class T>
94struct static_constant {
95 static T value;
96};
97
98template<class T>
99T static_constant<T>::value;
100
101//____________________________________________________________________________//
102
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.
107
108#define BOOST_TEST_SINGLETON_CONS_NO_CTOR( type ) \
109public: \
110 static type& instance(); \
111private: \
112 BOOST_DELETED_FUNCTION(type(type const&)) \
113 BOOST_DELETED_FUNCTION(type& operator=(type const&)) \
114 BOOST_DEFAULTED_FUNCTION(~type(), {}) \
115/**/
116
117#define BOOST_TEST_SINGLETON_CONS( type ) \
118 BOOST_TEST_SINGLETON_CONS_NO_CTOR(type) \
119private: \
120 BOOST_DEFAULTED_FUNCTION(type(), {}) \
121/**/
122
123#define BOOST_TEST_SINGLETON_CONS_IMPL( type ) \
124 type& type::instance() { \
125 static type the_inst; return the_inst; \
126 } \
127/**/
128
129//____________________________________________________________________________//
130
131#if defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4
132#define BOOST_TEST_SINGLETON_INST( inst ) \
133static BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN (inst, _t)::instance();
134
135#else
136
137#define BOOST_TEST_SINGLETON_INST( inst ) \
138namespace { BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN( inst, _t)::instance(); }
139
140#endif
141
142} // namespace unit_test
143} // namespace boost
144
145//____________________________________________________________________________//
146
147#include <boost/test/detail/enable_warnings.hpp>
148
149#endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
150

source code of include/boost/test/detail/global_typedef.hpp