|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2007-02-02 10:32:59
Thorsten Ottosen <thorsten.ottosen_at_[hidden]> writes:
> Hi,
>
> I couldn't find a way to do this. Maybe I have overlooked something.
> Anyway, making sure that operator<, operator== does the right thing is
> pretty important.
Strict weak ordering uses a single operations and does not relate two
operations. Thus you can test that < imposes a strict weak ordering,
but it can have nothing to do with ==. What you're testing below
would need some other name.
> I had in mind that I could say
>
> for( each i )
> for( each i2 )
> BOOST_CHECK_STRICT_WEAK_ORDERING( *i, *i2 );
>
> which would check something like the following:
>
> if( !(*i < *i2) && !(*i2 < *i) )
> {
> BOOST_CHECK( *i == *i2 );
> }
> else if( *i < *i2 )
> {
> BOOST_CHECK( *i != *i2 );
> BOOST_CHECK( !(*i2 < *i) );
> }
> else
> {
> BOOST_CHECK( *i2 < *i );
> BOOST_CHECK( !(*i2 < *i) );
> }
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk