Boost logo

Boost :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-07-21 10:23:49

> I think for the case you're testing above, a fully compile-time test is
> probably more appropriate.

But in this case you may not know what fails and where the errors are. The
only thing you will see is something like

> The problem we were discussing was the testing of the type_traits
> replacements. The problem with those is that commonly each trait template
> needs 20 or more one-line test cases. It's important to be able to say, on
> any given compiler, that you expect a particular subset of these cases to
> fail. I don't believe "number of expected failures" is useful at all. One
> needs to know which *specific* cases are expected to fail, so that when
> changes are made to the library you can tell exactly which failures are
> new/old. Having to make a separate function for each test case is too high
> a burden on the test writer.

It could be easily wrapped using macro and selfregistering mechanism (it was
proposed once), like his:

// here, for example we going to use one global test_suite;
// in general case you may create as much test_suites as you want, this way
separating test cases on categories
test_suite BOOST_TEST_SUITE( "boost::is_pointer test suite" );

// it is pseudo code; in fact we will need class-registrar that will do this
in constructor
#define REGISTER_TC( tc_function, parent_suite, should_fail ) \
parent_suite->add( ( &tc_function, should_fail )

// this I could add to test_suites support; name could be better
// it could be 2 different macro with and without third parameter
#define 1ASSERT_TC( assert_statement, parent_suite, should_fail ) \
void BOOST_JOIN( 1assert_tc, __LINE__ ) { assert_statement; } \
REGISTER_TC( BOOST_JOIN( 1assert_tc, __LINE__ ), parent_suite, should_fail )


// here how your test file will look like

1ASSERT_TC( BOOST_CHECK_IS_SAME( type1, type2 ), false );
1ASSERT_TC( BOOST_CHECK_IS_SAME( type3, type4 ), true );
1ASSERT_TC( BOOST_CHECK( boost::is_pointer<int*&>::value ), true );

> -Dave


Boost list run by bdawes at, gregod at, cpdaniel at, john at