|
Boost Users : |
Subject: Re: [Boost-users] Boost.Test - how to print the value of a variable in case of error?
From: Richard (legalize+jeeves_at_[hidden])
Date: 2010-06-24 11:34:28
[Please do not mail me a copy of your followup]
boost-users_at_[hidden] spake the secret code
<BD63511532FE974CBFF3543FD105DDC4437AAE6CDB_at_[hidden]> thusly:
>Imagine this:
>
>BOOST_CHECK_EQUAL(cont.erase(key),1u);
First, I recommend use of BOOST_REQUIRES_xxx instead of BOOST_CHECK_xxx.
>If it fails, it tells me this:
>
>basics.cpp(61): error in "test_case": check cont.erase(key) == 1u failed
>[0 != 1]
If you use BOOST_CHECK_MESSAGE(predicate, message), you can create a
custom failure message that contains additional context:
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include <cmath>
BOOST_AUTO_TEST_CASE( test )
{
double res = std::sin( 45. );
BOOST_WARN_MESSAGE( res > 1,
"sin(45){" << res << "} is <= 1. Hmm.. Strange. " );
}
-- "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/> Legalize Adulthood! <http://legalizeadulthood.wordpress.com>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net