Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-11-02 22:22:41


"Stephen Torri" <storri_at_[hidden]> wrote in message
news:1162505258.11639.6.camel_at_base.torri.org...
>I am finding that the BOOST_CHECK_THROW is not catching an exception
> class I made. Below is how I am calling it:
>
> void test_read_FAIL_EMPTY_READ ()
> {
> boost::uint32_t size = 0;
> boost::uint8_t* data = 0;
> boost::uint32_t length = 5;
>
> Memory_Map a_ref ( size );
> BOOST_CHECK_THROW ( a_ref.read ( data, length ),
> errors::IO_Exception );
> }
>
> The read function is suppose to throw an errors::IO_Exception(int) when
> it finds out that the length of the read exceeds the length of the
> Memory_Map. What I am finding out is that the exception is being thrown
> but no message from Boost telling me that exception errors::IO_Exception
> has occurred and calling this test a success.

BOOST_CHECK_THROW is used to check that an exception *is* thrown (primarily
as a responce to invalid input). So the the bahavior you describe is
correct. In this case condition is true (ie exception is thrown), so with
default log level no output is printed. Error is reported if there were no
target exception occured.

> Have I used the wrong macro?
>
> Stephen

Gennadiy


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