2
0
mirror of https://github.com/boostorg/test.git synced 2026-02-15 01:22:08 +00:00
Files
test/doc/components/test_tools/reference/BOOST_CHECK_NO_THROW.html
Gennadiy Rozental 470273247c in progress
[SVN r33126]
2006-02-26 20:13:01 +00:00

57 lines
2.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>The Test Tools</TITLE>
<LINK rel="stylesheet" type="text/css" href="../../../style/btl.css" media="screen">
<LINK rel="stylesheet" type="text/css" href="../../../style/btl-print.css" media="print">
<META http-equiv="Content-Language" content="en-us">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type="text/css">
H4
{
margin: 0px;
}
</STYLE>
</HEAD>
<BODY>
<DIV class="body">
<H3>BOOST_WARN_NO_THROW( statement )<BR>
BOOST_CHECK_NO_THROW( statement )<BR>
BOOST_REQUIRE_NO_THROW( statement )</H3>
<P class="first-line-indented">These tools are used to perform a &quot;no throw&quot;
check. Tool execute the supplied statement and check that it does not
throw any exceptions. Error would be reported by the framework even if test
statement appear directly in test case body and throw any exception. But
these tools allow to proceed further with test case in case of failure.</P>
<P class="first-line-indented">If check is successful, the tool produces a
confirmation message, in other case it produces an error message in a form &quot;error
in &lt;test case name&gt;: exception was thrown
by &lt;statement&gt;.</P>
<P class="first-line-indented">The only parameter is the statement to execute
while checking for exception. Use block statement if you want to execute
more than one statement.</P>
<H4>Example: test.cpp</H4>
<PRE class="code">#<SPAN class="reserv-word">define</SPAN> BOOST_TEST_MAIN<BR>#<SPAN class="reserv-word">include</SPAN> &lt;<SPAN class="literal">boost/test/unit_test.hpp</SPAN>&gt;<BR>
<SPAN class="reserv-word">class</SPAN> my_exception{};
BOOST_AUTO_TEST_CASE( test )
{
BOOST_CHECK_NO_THROW( <SPAN class="reserv-word">throw</SPAN> my_exception() );
}</PRE>
<H4>Output:</H4>
<P class="test-output">Running 1 test case...<BR>
test.cpp(8): error in &quot;test&quot;: exception thrown by throw my_exception()<BR>
<BR>
***
1 failure detected in test suite &quot;Master Test Suite&quot;</P>
<DIV class="see_also">
<H4>See Also</H4>
<P class="see-also-content"><A href="BOOST_CHECK_THROW.html" target="descr">BOOST_CHECK_THROW</A></P>
</DIV>
</DIV>
</BODY>
</HTML>
<!-- Copyright Gennadiy Rozental 2001-2006.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt) -->