Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/test/example/unit_test_example2.cpp @ 20

Last change on this file since 20 was 12, checked in by landauf, 18 years ago

added boost

File size: 1.2 KB
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>
11using boost::unit_test::test_suite;
12
13void force_division_by_zero()
14{
15    // unit test framework can catch operating system signals
16    BOOST_CHECKPOINT("About to force division by zero!");
17    int i = 1, j = 0;
18    i = i / j;
19}
20
21void infinite_loop()
22{
23    // unit test framework can break infinite loops by timeout
24#ifdef __unix  // don't have timeout on other platforms
25    BOOST_CHECKPOINT("About to enter an infinite loop!");
26    while(1);
27#else
28    BOOST_MESSAGE( "Timeout support is not implemented on your platform" );
29#endif
30}
31
32test_suite*
33init_unit_test_suite( int argc, char * argv[] ) {
34    test_suite* test= BOOST_TEST_SUITE( "Unit test example 2" );
35
36    test->add( BOOST_TEST_CASE( &force_division_by_zero ) );
37    test->add( BOOST_TEST_CASE( &infinite_loop ), 0, /* timeout */ 2 );
38
39    return test; 
40}
41
42// EOF
Note: See TracBrowser for help on using the repository browser.