Rev | Line | |
---|
[9020] | 1 | #include <boost/test/minimal.hpp> |
---|
| 2 | |
---|
| 3 | //____________________________________________________________________________// |
---|
| 4 | |
---|
| 5 | int add( int i, int j ) { return i+j; } |
---|
| 6 | |
---|
| 7 | //____________________________________________________________________________// |
---|
| 8 | |
---|
| 9 | int test_main( int, char *[] ) // note the name! |
---|
| 10 | { |
---|
| 11 | // six ways to detect and report the same error: |
---|
| 12 | BOOST_CHECK( add( 2,2 ) == 4 ); // #1 continues on error |
---|
| 13 | BOOST_REQUIRE( add( 2,2 ) == 4 ); // #2 throws on error |
---|
| 14 | if( add( 2,2 ) != 4 ) |
---|
| 15 | BOOST_ERROR( "Ouch..." ); // #3 continues on error |
---|
| 16 | if( add( 2,2 ) != 4 ) |
---|
| 17 | BOOST_FAIL( "Ouch..." ); // #4 throws on error |
---|
| 18 | if( add( 2,2 ) != 4 ) throw "Oops..."; // #5 throws on error |
---|
| 19 | |
---|
| 20 | return add( 2, 2 ) == 4 ? 0 : 1; // #6 returns error code |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | //____________________________________________________________________________// |
---|
Note: See
TracBrowser
for help on using the repository browser.