Add throw_from_library_test

This commit is contained in:
Peter Dimov
2018-09-25 20:55:04 +03:00
parent ee45839a78
commit 614cbc4f34
8 changed files with 173 additions and 6 deletions

View File

@ -7,15 +7,16 @@
import testing ; import testing ;
project
: requirements
<link>static
<exception-handling>on
;
run throw_exception_test.cpp ; run throw_exception_test.cpp ;
run throw_exception_no_exceptions_test.cpp ; run throw_exception_no_exceptions_test.cpp ;
run throw_exception_no_integration_test.cpp ; run throw_exception_no_integration_test.cpp ;
run throw_exception_no_both_test.cpp ; run throw_exception_no_both_test.cpp ;
compile-fail throw_exception_fail.cpp ; compile-fail throw_exception_fail.cpp ;
lib lib1_throw : lib1_throw.cpp : <define>LIB1_SOURCE=1 <link>shared:<define>LIB1_DYN_LINK=1 : : <link>shared:<define>LIB1_DYN_LINK=1 ;
lib lib2_throw : lib2_throw.cpp : <define>LIB2_SOURCE=1 <link>shared:<define>LIB2_DYN_LINK=1 : : <link>shared:<define>LIB2_DYN_LINK=1 ;
lib lib3_throw : lib3_throw.cpp : <define>LIB3_SOURCE=1 <link>shared:<define>LIB3_DYN_LINK=1 : : <link>shared:<define>LIB3_DYN_LINK=1 ;
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>static : throw_from_library_static ;
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>shared : throw_from_library_shared ;

13
test/lib1_throw.cpp Normal file
View File

@ -0,0 +1,13 @@
// Copyright 2018 Peter Dimov
//
// 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 "lib1_throw.hpp"
void lib1::f()
{
throw lib1::exception();
}

35
test/lib1_throw.hpp Normal file
View File

@ -0,0 +1,35 @@
#ifndef LIB1_THROW_HPP_INCLUDED
#define LIB1_THROW_HPP_INCLUDED
// Copyright 2018 Peter Dimov
//
// 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>
#include <exception>
#if defined(LIB1_DYN_LINK)
# if defined(LIB1_SOURCE)
# define LIB1_DECL BOOST_SYMBOL_EXPORT
# else
# define LIB1_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define LIB1_DECL
#endif
namespace lib1
{
struct exception: public std::exception
{
};
LIB1_DECL void f();
} // namespace lib1
#endif // #ifndef LIB1_THROW_HPP_INCLUDED

14
test/lib2_throw.cpp Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2018 Peter Dimov
//
// 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 "lib2_throw.hpp"
#include <boost/throw_exception.hpp>
void lib2::f()
{
boost::throw_exception( lib2::exception() );
}

35
test/lib2_throw.hpp Normal file
View File

@ -0,0 +1,35 @@
#ifndef LIB2_THROW_HPP_INCLUDED
#define LIB2_THROW_HPP_INCLUDED
// Copyright 2018 Peter Dimov
//
// 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>
#include <exception>
#if defined(LIB2_DYN_LINK)
# if defined(LIB2_SOURCE)
# define LIB2_DECL BOOST_SYMBOL_EXPORT
# else
# define LIB2_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define LIB2_DECL
#endif
namespace lib2
{
struct exception: public std::exception
{
};
LIB2_DECL void f();
} // namespace lib2
#endif // #ifndef LIB2_THROW_HPP_INCLUDED

14
test/lib3_throw.cpp Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2018 Peter Dimov
//
// 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 "lib3_throw.hpp"
#include <boost/throw_exception.hpp>
void lib3::f()
{
BOOST_THROW_EXCEPTION( lib3::exception() );
}

35
test/lib3_throw.hpp Normal file
View File

@ -0,0 +1,35 @@
#ifndef LIB3_THROW_HPP_INCLUDED
#define LIB3_THROW_HPP_INCLUDED
// Copyright 2018 Peter Dimov
//
// 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>
#include <exception>
#if defined(LIB3_DYN_LINK)
# if defined(LIB3_SOURCE)
# define LIB3_DECL BOOST_SYMBOL_EXPORT
# else
# define LIB3_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define LIB3_DECL
#endif
namespace lib3
{
struct exception: public std::exception
{
};
LIB3_DECL void f();
} // namespace lib3
#endif // #ifndef LIB3_THROW_HPP_INCLUDED

View File

@ -0,0 +1,20 @@
// Copyright 2018 Peter Dimov
//
// 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 "lib1_throw.hpp"
#include "lib2_throw.hpp"
#include "lib3_throw.hpp"
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST_THROWS( lib1::f(), lib1::exception );
BOOST_TEST_THROWS( lib2::f(), lib2::exception );
BOOST_TEST_THROWS( lib3::f(), lib3::exception );
return boost::report_errors();
}