mirror of
https://github.com/boostorg/test.git
synced 2026-01-26 19:12:10 +00:00
127 lines
3.5 KiB
C++
127 lines
3.5 KiB
C++
// (C) Copyright Gennadiy Rozental 2001-2004.
|
|
// 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$
|
|
//
|
|
// Version : $Revision$
|
|
//
|
|
// Description : tests an extentions to Unit Test Framework
|
|
// ***************************************************************************
|
|
|
|
// Boost.Test
|
|
#include <boost/test/unit_test_suite_ex.hpp>
|
|
#include <boost/test/test_tools.hpp>
|
|
|
|
using boost::unit_test::test_suite;
|
|
|
|
#if !defined(BOOST_MSVC) && !defined(__SUNPRO_CC)
|
|
// BOOST
|
|
#include <boost/bind.hpp>
|
|
#endif
|
|
|
|
#include <boost/function.hpp>
|
|
using namespace boost;
|
|
|
|
// STL
|
|
#include <list>
|
|
#include <utility>
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
void test0()
|
|
{
|
|
BOOST_MESSAGE( "Hello there" );
|
|
}
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
void test1( int arg )
|
|
{
|
|
BOOST_CHECK( (arg & 0x80) == 0 );
|
|
}
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
void test2( int arg, int mask )
|
|
{
|
|
BOOST_CHECK( (arg & mask) != 0 );
|
|
}
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
struct sub_test_suite : public test_suite {
|
|
typedef std::list<std::pair<int,int> > mask_list_type;
|
|
sub_test_suite()
|
|
{
|
|
parameters_list.push_back( 1 );
|
|
parameters_list.push_back( 5 );
|
|
parameters_list.push_back( 6 );
|
|
parameters_list.push_back( 7 );
|
|
parameters_list.push_back( 15 );
|
|
|
|
masks_list.push_back( std::make_pair( 0x01, 1 ) );
|
|
masks_list.push_back( std::make_pair( 0x04, 1 ) );
|
|
masks_list.push_back( std::make_pair( 0x80, 5 ) );
|
|
|
|
|
|
#if !defined(BOOST_MSVC) && !defined(__SUNPRO_CC)
|
|
for( mask_list_type::iterator it = masks_list.begin(); it != masks_list.end(); ++it ) {
|
|
function1<void,int> fct = bind( &test2, _1, it->first );
|
|
add( BOOST_PARAM_TEST_CASE( fct, parameters_list.begin(), parameters_list.end() ), it->second );
|
|
}
|
|
#endif
|
|
|
|
function1<void,int> fct = &test1;
|
|
add( BOOST_PARAM_TEST_CASE( fct, parameters_list.begin(), parameters_list.end() ) );
|
|
}
|
|
|
|
|
|
std::list<int> parameters_list;
|
|
mask_list_type masks_list; // mask/"num of errors expected" list
|
|
};
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
test_suite*
|
|
init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) {
|
|
test_suite* test = BOOST_TEST_SUITE("unit_test_suite extensions test");
|
|
|
|
function0<void> fct1 = &test0;
|
|
test->add( BOOST_TEST_CASE( fct1 ) );
|
|
|
|
#if !defined(BOOST_MSVC) && !defined(__SUNPRO_CC)
|
|
function0<void> fct2 = bind( &test2, 12345, 0xcdf );
|
|
test->add( BOOST_TEST_CASE( fct2 ) );
|
|
#endif
|
|
|
|
test->add( new sub_test_suite );
|
|
|
|
return test;
|
|
}
|
|
|
|
//____________________________________________________________________________//
|
|
|
|
// ***************************************************************************
|
|
// Revision History :
|
|
//
|
|
// $Log$
|
|
// Revision 1.15 2004/05/21 06:26:11 rogeeff
|
|
// licence update
|
|
//
|
|
// Revision 1.14 2004/05/11 11:05:06 rogeeff
|
|
// basic_cstring introduced and used everywhere
|
|
// class properties reworked
|
|
// namespace names shortened
|
|
//
|
|
// Revision 1.13 2003/12/01 00:42:38 rogeeff
|
|
// prerelease cleaning
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// EOF
|