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 #include <boost/test/detail/workaround.hpp>
17 
18 #define BOOST_TEST_L( s )         ::boost::unit_test::const_string( s, sizeof( s ) - 1 )
19 #define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) )
20 #define BOOST_TEST_EMPTY_STRING   BOOST_TEST_L( "" )
21 
22 #include <boost/test/detail/suppress_warnings.hpp>
23 
24 //____________________________________________________________________________//
25 
26 namespace boost {
27 namespace unit_test {
28 
29 typedef unsigned long   counter_t;
30 
31 //____________________________________________________________________________//
32 
33 enum report_level  { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
34 
35 //____________________________________________________________________________//
36 
37 //! Indicates the output format for the loggers or the test tree printing
38 enum output_format { OF_INVALID,
39                      OF_CLF,      ///< compiler log format
40                      OF_XML,      ///< XML format for report and log,
41                      OF_JUNIT,    ///< JUNIT format for report and log,
42                      OF_CUSTOM_LOGGER, ///< User specified logger.
43                      OF_DOT       ///< dot format for output content
44 };
45 
46 //____________________________________________________________________________//
47 
48 enum test_unit_type { TUT_CASE = 0x01, TUT_SUITE = 0x10, TUT_ANY = 0x11 };
49 
50 //____________________________________________________________________________//
51 
52 enum assertion_result { AR_FAILED, AR_PASSED, AR_TRIGGERED };
53 
54 //____________________________________________________________________________//
55 
56 typedef unsigned long   test_unit_id;
57 
58 const test_unit_id INV_TEST_UNIT_ID  = 0xFFFFFFFF;
59 const test_unit_id MAX_TEST_CASE_ID  = 0xFFFFFFFE;
60 const test_unit_id MIN_TEST_CASE_ID  = 0x00010000;
61 const test_unit_id MAX_TEST_SUITE_ID = 0x0000FF00;
62 const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
63 
64 //____________________________________________________________________________//
65 
66 namespace ut_detail {
67 
68 inline test_unit_type
test_id_2_unit_type(test_unit_id id)69 test_id_2_unit_type( test_unit_id id )
70 {
71     return (id & 0xFFFF0000) != 0 ? TUT_CASE : TUT_SUITE;
72 }
73 
74 //! Helper class for restoring the current test unit ID in a RAII manner
75 struct test_unit_id_restore {
test_unit_id_restoreboost::unit_test::ut_detail::test_unit_id_restore76     test_unit_id_restore(test_unit_id& to_restore_, test_unit_id new_value)
77     : to_restore(to_restore_)
78     , bkup(to_restore_) {
79         to_restore = new_value;
80     }
~test_unit_id_restoreboost::unit_test::ut_detail::test_unit_id_restore81     ~test_unit_id_restore() {
82         to_restore = bkup;
83     }
84 private:
85     test_unit_id& to_restore;
86     test_unit_id bkup;
87 };
88 
89 //____________________________________________________________________________//
90 
91 } // namespace ut_detail
92 
93 // helper templates to prevent ODR violations
94 template<class T>
95 struct static_constant {
96     static T value;
97 };
98 
99 template<class T>
100 T static_constant<T>::value;
101 
102 //____________________________________________________________________________//
103 
104 } // namespace unit_test
105 } // namespace boost
106 
107 //____________________________________________________________________________//
108 
109 #include <boost/test/detail/enable_warnings.hpp>
110 
111 #endif // BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER
112