blob: 43d249d5338e54b63621dee2c5b235695100c315 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8// File : $RCSfile$
9//
10// Version : $Revision: 54633 $
11//
12// Description : defines framework interface
13// ***************************************************************************
14
15#ifndef BOOST_TEST_FRAMEWORK_HPP_020805GER
16#define BOOST_TEST_FRAMEWORK_HPP_020805GER
17
18// Boost.Test
19#include <ndnboost/test/detail/global_typedef.hpp>
20#include <ndnboost/test/detail/fwd_decl.hpp>
21#include <ndnboost/test/utils/trivial_singleton.hpp>
22
23#include <ndnboost/test/detail/suppress_warnings.hpp>
24
25// STL
26#include <stdexcept>
27
28//____________________________________________________________________________//
29
30namespace ndnboost {
31
32namespace unit_test {
33
34// ************************************************************************** //
35// ************** init_unit_test_func ************** //
36// ************************************************************************** //
37
38#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
39typedef bool (*init_unit_test_func)();
40#else
41typedef test_suite* (*init_unit_test_func)( int, char* [] );
42#endif
43
44// ************************************************************************** //
45// ************** framework ************** //
46// ************************************************************************** //
47
48namespace framework {
49
50// initialization
51BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] );
52BOOST_TEST_DECL bool is_initialized();
53
54// mutation access methods
55BOOST_TEST_DECL void register_test_unit( test_case* tc );
56BOOST_TEST_DECL void register_test_unit( test_suite* ts );
57BOOST_TEST_DECL void deregister_test_unit( test_unit* tu );
58BOOST_TEST_DECL void clear();
59
60BOOST_TEST_DECL void register_observer( test_observer& );
61BOOST_TEST_DECL void deregister_observer( test_observer& );
62BOOST_TEST_DECL void reset_observers();
63
64BOOST_TEST_DECL master_test_suite_t& master_test_suite();
65
66// constant access methods
67BOOST_TEST_DECL test_case const& current_test_case();
68
69BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type );
70template<typename UnitType>
71UnitType& get( test_unit_id id )
72{
73 return static_cast<UnitType&>( get( id, static_cast<test_unit_type>(UnitType::type) ) );
74}
75
76// test initiation
77BOOST_TEST_DECL void run( test_unit_id = INV_TEST_UNIT_ID, bool continue_test = true );
78BOOST_TEST_DECL void run( test_unit const*, bool continue_test = true );
79
80// public test events dispatchers
81BOOST_TEST_DECL void assertion_result( bool passed );
82BOOST_TEST_DECL void exception_caught( execution_exception const& );
83BOOST_TEST_DECL void test_unit_aborted( test_unit const& );
84
85// ************************************************************************** //
86// ************** framework errors ************** //
87// ************************************************************************** //
88
89struct internal_error : std::runtime_error {
90 internal_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
91};
92
93struct setup_error : std::runtime_error {
94 setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
95};
96
97#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg )
98
99struct nothing_to_test {}; // not really an error
100
101} // namespace framework
102
103} // unit_test
104
105} // namespace ndnboost
106
107//____________________________________________________________________________//
108
109#include <ndnboost/test/detail/enable_warnings.hpp>
110
111#endif // BOOST_TEST_FRAMEWORK_HPP_020805GER
112