2 / Copyright (c) 2003-2015 Boost.Test contributors
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 [/ ################################################ ]
10 [section:exception_correctness Exception correctness]
12 Any unexpected/uncaught exception raised in the test case body will be intercepted by the Boost.test
13 framework and will result in the termination of the test-case with the status `failed`.
15 [bt_example exception_uncaught..Uncaught exception..run-fail]
17 More control over the exception correctness is often required, for instance to test that
18 an expression is raising a specific exception, intentionally.
20 The __UTF__ provides several assertions for testing a code with respect to the exceptions correctness.
21 The following assertions are available:
23 * __BOOST_LEVEL_NO_THROW__ checks that no exception is raised from an expression,
24 * __BOOST_LEVEL_THROW__ checks that an expression raises an exception of a specific type
25 * __BOOST_LEVEL_EXCEPTION__ checks that an expression raises an exception of a specific type,
26 a passes the exception instance to a predicate function for further validation (introspection
29 The following example demonstrate how to use these tools to test the correct behavior of the API
30 of `FileWordHistogram`, in the constructor and the preconditions of the member function.
32 [bt_example exception_api..Exception correctness of an API..run-fail]
34 [note An `assert(...)` might call `abort()`: the use of the macros above may not be
35 suitable for testing for `assert`'s in a portable manner. ]
37 [h4 Bibliographic references]
39 [variablelist Publications
41 [[@https://isocpp.org/wiki/faq/exceptions
42 Exceptions and Error Handling]]
43 [Standard C++ Foundation]