Fix and unit test for issue #37

This commit is contained in:
Emil Dotchevski
2021-02-11 16:02:14 -08:00
parent e69635b1a7
commit 20c833978f
7 changed files with 62 additions and 10 deletions

View File

@ -7,11 +7,6 @@
import testing ;
project
: requirements
<link>static
;
#to_string
run is_output_streamable_test.cpp ;
@ -47,6 +42,9 @@ run errinfos_test.cpp : : : <exception-handling>on ;
run exception_ptr_test.cpp/<define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : <threading>multi <exception-handling>on : non_intrusive_exception_ptr_test ;
run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : <threading>multi <exception-handling>on ;
lib visibility_test_lib : visibility_test_lib.cpp : <visibility>hidden <exception-handling>on ;
run visibility_test.cpp visibility_test_lib/<link>shared : : : <visibility>hidden <exception-handling>on ;
compile-fail exception_fail.cpp ;
compile-fail throw_exception_fail.cpp ;
compile-fail error_info_const_fail.cpp ;

32
test/visibility_test.cpp Normal file
View File

@ -0,0 +1,32 @@
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if defined( BOOST_NO_EXCEPTIONS )
# error This program requires exception handling.
#endif
#include "visibility_test_lib.hpp"
#include <boost/exception/get_error_info.hpp>
#include <boost/detail/lightweight_test.hpp>
void BOOST_SYMBOL_IMPORT hidden_throw();
int
main()
{
try
{
hidden_throw();
BOOST_TEST(false);
}
catch(
my_exception & e )
{
BOOST_TEST(boost::get_error_info<my_info>(e) && *boost::get_error_info<my_info>(e)==42);
}
return boost::report_errors();
}

View File

@ -0,0 +1,9 @@
#include "visibility_test_lib.hpp"
#include <boost/throw_exception.hpp>
void
BOOST_SYMBOL_EXPORT
hidden_throw()
{
BOOST_THROW_EXCEPTION(my_exception() << my_info(42));
}

View File

@ -0,0 +1,15 @@
#ifndef HIDDEN_HPP_INCLUDED
#define HIDDEN_HPP_INCLUDED
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/exception/info.hpp>
typedef boost::error_info<struct my_info_, int> my_info;
struct BOOST_SYMBOL_VISIBLE my_exception: virtual std::exception, virtual boost::exception { };
#endif