Boost-Graph
view release on metacpan or search on metacpan
include/boost/test/impl/framework.ipp view on Meta::CPAN
// (C) Copyright Gennadiy Rozental 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
// File : $RCSfile: framework.ipp,v $
//
// Version : $Revision: 1.6 $
//
// Description : implements framework songleton - main driver for the test
// ***************************************************************************
#ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER
#define BOOST_TEST_FRAMEWORK_IPP_021005GER
// Boost.Test
#include <boost/test/framework.hpp>
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/unit_test_log.hpp>
#include <boost/test/unit_test_monitor.hpp>
#include <boost/test/test_observer.hpp>
#include <boost/test/results_collector.hpp>
#include <boost/test/progress_monitor.hpp>
#include <boost/test/results_reporter.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/detail/unit_test_parameters.hpp>
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/utils/foreach.hpp>
// Boost
#include <boost/timer.hpp>
// STL
#include <map>
#include <stdexcept>
#include <cstdlib>
#include <ctime>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std { using ::time; using ::srand; }
#endif
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
// prototype for user's test suite init function
extern boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] );
namespace boost {
namespace unit_test {
// ************************************************************************** //
// ************** framework ************** //
// ************************************************************************** //
class framework_impl : public test_tree_visitor {
public:
framework_impl()
: m_master_test_suite( INV_TEST_UNIT_ID )
, m_curr_test_case( INV_TEST_UNIT_ID )
, m_next_test_case_id( MIN_TEST_CASE_ID )
, m_next_test_suite_id( MIN_TEST_SUITE_ID )
, m_test_in_progress( false )
{}
~framework_impl()
{
BOOST_TEST_FOREACH( test_unit_store::value_type const&, tu, m_test_units ) {
if( test_id_2_unit_type( tu.second->p_id ) == tut_suite )
delete (test_suite const*)tu.second;
else
delete (test_case const*)tu.second;
}
}
void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; }
// test_tree_visitor interface implementation
void visit( test_case const& tc )
{
if( !tc.check_dependencies() ) {
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_skipped( tc );
return;
}
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_start( tc );
boost::timer tc_timer;
test_unit_id bkup = m_curr_test_case;
m_curr_test_case = tc.p_id;
unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc );
unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 );
if( unit_test_monitor.is_critical_error( run_result ) ) {
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_aborted();
}
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_finish( tc, elapsed );
m_curr_test_case = bkup;
if( unit_test_monitor.is_critical_error( run_result ) )
throw test_aborted();
}
bool test_suite_start( test_suite const& ts )
{
if( !ts.check_dependencies() ) {
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_skipped( ts );
return false;
}
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_start( ts );
return true;
}
void test_suite_finish( test_suite const& ts )
{
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_finish( ts, 0 );
}
//////////////////////////////////////////////////////////////////
typedef std::map<test_unit_id,test_unit const*> test_unit_store;
typedef std::list<test_observer*> observer_store;
test_unit_id m_master_test_suite;
test_unit_id m_curr_test_case;
test_unit_store m_test_units;
test_unit_id m_next_test_case_id;
test_unit_id m_next_test_suite_id;
bool m_test_in_progress;
observer_store m_observers;
};
//____________________________________________________________________________//
namespace {
framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; }
( run in 0.805 second using v1.01-cache-2.11-cpan-39bf76dae61 )