Boost logo

Boost :

Subject: Re: [boost] Regression testing unobservable behavior?
From: Peter Dimov (lists_at_[hidden])
Date: 2014-08-08 10:53:30


Beman Dawes wrote:
On Fri, Aug 8, 2014 at 9:53 AM, Peter Dimov <lists_at_[hidden]> wrote:
>
> > Beman Dawes wrote:
> >
> >> Certain library function errors are difficult to regression test
> >> because it is not obvious how to observe their behavior in a test
> >> framework.
> >> Examples include:
> >>
> >> ...
> >
> > 2) Verification that BOOST_ASSERT fires when a precondition is
> > violated.
> >
> > You can do this by enabling a custom assert handler and then test that
> > it has been invoked.
>
> Yes, but the question in my mind is how to "test that it has been
> invoked"?

I just do the obvious: increment an "assertion_failed_" global variable in
the handler, then BOOST_TEST that it has been incremented the correct number
of times.

It's a bit ad-hoc, but it works.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk