|
Boost : |
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-07-21 01:31:58
> > > > > Yeah, testing this library is difficult. I'd be interested in
> > > > > discussing what an improved test would look like.
> >
> > Not that I thrust myself, but naybe new Test Library could help?
>
> I would hope so...
>
> -Dave
Here how one of the MPL tests would look like ( copyright comments removed):
#include <boost/test/unit_test.hpp>
using namespace boost::unit_test_framework;
// In fact I think following belongs to test tools, or maybe to test tools
extension I can provide, in which case output will be much more expressive
// something like: "file(line): test iter1 same as first fails: int_c<0> is
not the same as int<1>"
#define BOOST_CHECK_IS_SAME( type1, type2 ) \
BOOST_CHECK( boost::is_same< type1, type2 >::value )
#include "boost/mpl/vector/vector10_c.hpp"
#include "boost/mpl/advance.hpp"
#include "boost/mpl/begin_end.hpp"
namespace mpl = boost::mpl;
void test_advance()
{
typedef mpl::vector10_c<int,0,1,2,3,4,5,6,7,8,9> numbers;
typedef mpl::begin<numbers>::type first;
typedef mpl::end<numbers>::type last;
typedef mpl::advance_c<first,10>::type iter1;
typedef mpl::advance_c<last,-10>::type iter2;
BOOST_CHECK_IS_SAME(iter1, last);
BOOST_CHECK_IS_SAME(iter2, first);
}
test_suite*
init_unit_test_suite( int argc, char* argv[] ) {
test_suite* test = BOOST_TEST_SUITE( "MPL unit test" );
test->add( BOOST_TEST_CASE( &test_advance ), /* 1 - here you could pun
expected number of failures */ );
// BTW I do not see a reason why should we keep one test case per file,
since all test cases are named
// here we could have as much test->add( BOOST_TEST_CASE( &test_??? ) as
we want
return test;
}
What do you think?
Gennadiy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk