| Line | |
|---|
| 1 | // (C) Copyright Gennadiy Rozental 2002-2005. |
|---|
| 2 | // (C) Copyright Gennadiy Rozental & Ullrich Koethe 2001. |
|---|
| 3 | // Distributed under the Boost Software License, Version 1.0. |
|---|
| 4 | // (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 5 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 6 | |
|---|
| 7 | // See http://www.boost.org/libs/test for the library home page. |
|---|
| 8 | |
|---|
| 9 | // Boost.Test |
|---|
| 10 | #include <boost/test/unit_test.hpp> |
|---|
| 11 | using boost::unit_test::test_suite; |
|---|
| 12 | |
|---|
| 13 | // most frequently you implement test cases as a free functions |
|---|
| 14 | void free_test_function() |
|---|
| 15 | { |
|---|
| 16 | // reports 'error in "free_test_function": test 2 == 1 failed' |
|---|
| 17 | BOOST_CHECK(2 == 1); // non-critical test => continue after failure |
|---|
| 18 | |
|---|
| 19 | int* p = (int*)0; |
|---|
| 20 | *p = 0; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | test_suite* |
|---|
| 24 | init_unit_test_suite( int, char* [] ) { |
|---|
| 25 | test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); |
|---|
| 26 | |
|---|
| 27 | // this example will pass cause we know ahead of time number of expected failures |
|---|
| 28 | test->add( BOOST_TEST_CASE( &free_test_function ), 1 /* expected one error */ ); |
|---|
| 29 | |
|---|
| 30 | return test; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | // EOF |
|---|
Note: See
TracBrowser
for help on using the repository browser.