Ticket #2349: boost.test-execution_monitor-terminate-testcases.diff

File boost.test-execution_monitor-terminate-testcases.diff, 3.6 KB (added by Norbert Buchmuller <norbi@…>, 14 years ago)

Patch to create test cases for std::bad_exception and terminate().

  • libs/test/test/prg_exec_fail5.cpp

     
     1//  (C) Copyright Gennadiy Rozental 2001-2008.
     2//  (C) Copyright Beman Dawes 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//  File        : $RCSfile$
     10//
     11//  Version     : $Revision$
     12//
     13//  Description : tests the ability of Program Execution Monitor to catch
     14//  unexpected exceptions when std::bad_exception is allowed.
     15//  Should fail during run.
     16// ***************************************************************************
     17
     18#include <stdexcept>
     19
     20#include <boost/test/included/prg_exec_monitor.hpp>
     21
     22void func() throw(std::bad_exception)
     23{
     24        throw "Test error by throwing C-style string exception";
     25}
     26
     27int
     28cpp_main( int argc, char *[] )  // note the name
     29{
     30    if( argc > 0 ) // to prevent the unreachable return warning
     31        func();
     32
     33    return 0;
     34}
     35
     36//____________________________________________________________________________//
     37
     38// EOF
  • libs/test/test/prg_exec_fail6.cpp

    Property changes on: libs/test/test/prg_exec_fail5.cpp
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
     1//  (C) Copyright Gennadiy Rozental 2001-2008.
     2//  (C) Copyright Beman Dawes 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//  File        : $RCSfile$
     10//
     11//  Version     : $Revision$
     12//
     13//  Description : tests the ability of Program Execution Monitor to catch
     14//  unexpected exceptions when std::bad_exception is not allowed.
     15//  Should fail during run.
     16// ***************************************************************************
     17
     18#include <stdexcept>
     19
     20#include <boost/test/included/prg_exec_monitor.hpp>
     21
     22void func() throw()
     23{
     24        throw "Test error by throwing C-style string exception";
     25}
     26
     27int
     28cpp_main( int argc, char *[] )  // note the name
     29{
     30    if( argc > 0 ) // to prevent the unreachable return warning
     31        func();
     32
     33    return 0;
     34}
     35
     36//____________________________________________________________________________//
     37
     38// EOF
  • libs/test/test/Jamfile.v2

    Property changes on: libs/test/test/prg_exec_fail6.cpp
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
    3838          [ test-btl-lib run-fail : prg_exec_fail2 : boost_prg_exec_monitor/<link>static ]
    3939          [ test-btl-lib run-fail : prg_exec_fail3 : boost_prg_exec_monitor/<link>static ]
    4040          [ test-btl-lib run-fail : prg_exec_fail4 : boost_prg_exec_monitor/<link>static ]
     41          [ test-btl-lib run-fail : prg_exec_fail5 : boost_prg_exec_monitor/<link>static ]
     42          [ test-btl-lib run-fail : prg_exec_fail6 : boost_prg_exec_monitor/<link>static ]
    4143        ;
    4244
    4345test-suite "unit_test_framework_test"