fix doc example typo
[boost.git] / boost / test / framework.hpp
blob60a0aa1e025a239b095048711160285c28dd859e
1 // (C) Copyright Gennadiy Rozental 2005-2008.
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.
7 //
8 // File : $RCSfile$
9 //
10 // Version : $Revision$
12 // Description : defines framework interface
13 // ***************************************************************************
15 #ifndef BOOST_TEST_FRAMEWORK_HPP_020805GER
16 #define BOOST_TEST_FRAMEWORK_HPP_020805GER
18 // Boost.Test
19 #include <boost/test/detail/global_typedef.hpp>
20 #include <boost/test/detail/fwd_decl.hpp>
21 #include <boost/test/utils/trivial_singleton.hpp>
23 #include <boost/test/detail/suppress_warnings.hpp>
25 // STL
26 #include <stdexcept>
28 //____________________________________________________________________________//
30 namespace boost {
32 namespace unit_test {
34 // ************************************************************************** //
35 // ************** init_unit_test_func ************** //
36 // ************************************************************************** //
38 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
39 typedef bool (*init_unit_test_func)();
40 #else
41 typedef test_suite* (*init_unit_test_func)( int, char* [] );
42 #endif
44 // ************************************************************************** //
45 // ************** framework ************** //
46 // ************************************************************************** //
48 namespace framework {
50 // initialization
51 BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] );
52 BOOST_TEST_DECL bool is_initialized();
54 // mutation access methods
55 BOOST_TEST_DECL void register_test_unit( test_case* tc );
56 BOOST_TEST_DECL void register_test_unit( test_suite* ts );
57 BOOST_TEST_DECL void deregister_test_unit( test_unit* tu );
58 BOOST_TEST_DECL void clear();
60 BOOST_TEST_DECL void register_observer( test_observer& );
61 BOOST_TEST_DECL void deregister_observer( test_observer& );
62 BOOST_TEST_DECL void reset_observers();
64 BOOST_TEST_DECL master_test_suite_t& master_test_suite();
66 // constant access methods
67 BOOST_TEST_DECL test_case const& current_test_case();
69 BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type );
70 template<typename UnitType>
71 UnitType& get( test_unit_id id )
73 return static_cast<UnitType&>( get( id, (test_unit_type)UnitType::type ) );
76 // test initiation
77 BOOST_TEST_DECL void run( test_unit_id = INV_TEST_UNIT_ID, bool continue_test = true );
78 BOOST_TEST_DECL void run( test_unit const*, bool continue_test = true );
80 // public test events dispatchers
81 BOOST_TEST_DECL void assertion_result( bool passed );
82 BOOST_TEST_DECL void exception_caught( execution_exception const& );
83 BOOST_TEST_DECL void test_unit_aborted( test_unit const& );
85 // ************************************************************************** //
86 // ************** framework errors ************** //
87 // ************************************************************************** //
89 struct internal_error : std::runtime_error {
90 internal_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
93 struct setup_error : std::runtime_error {
94 setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
97 #define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg )
99 struct nothing_to_test {}; // not really an error
101 } // namespace framework
103 } // unit_test
105 } // namespace boost
107 //____________________________________________________________________________//
109 #include <boost/test/detail/enable_warnings.hpp>
111 #endif // BOOST_TEST_FRAMEWORK_HPP_020805GER