Boost logo

Boost Users :

Subject: Re: [Boost-users] [Test] Boost.Test for Property Tree Issue
From: Richard (legalize+jeeves_at_[hidden])
Date: 2014-05-19 17:13:46


[Please do not mail me a copy of your followup]

boost-users_at_[hidden] spake the secret code
<CACHJcDyJgC7KMTQNOUXFBOK3x+sF89Oyo7NxNeN1q3qjfLpFrg_at_[hidden]> thusly:

>Boost version: 1.55.0
>OS: Windows 8
>IDE: Visual Studio 2010
>I have a small class which just parses a std::string
>using boost::property_tree::read_json.
>I'm trying to test my method with invalid input to make sure my method
>handles the exception.
>However, when I execute GetPropertyTreeFromJsonInValidInput2 (source code
> in attachment), I get exception
>in the visual studio itself and I have to break the execution. (snapshot is
>included in attachment).
>I'm a new user of boost, so don't know where to look for the solution.

The test framework catches all thrown exceptions and turns them into a
test failure.

I see a couple issues with your tests.

First, you're launching a thread in one of the tests. Why?
The recommendation is to test threading functionality separately from
application functionality.

Second, you're using the heap for your JsonParser instances and this
is totally unnecessary -- just create them on the stack.

Are you running your test executable in the debugger?

I don't have VS 2010 installed on my machine anymore, but under VS
2012, there is a menu item Debug / Exceptions... that brings up a
dialog where you can configure how the debugger treats exceptions. In
the list you should see C++ Exceptions / std::exception and checkboxes
in the Thrown and User-unhandled columns.

These settings control how the debugger deals with exceptions, so you
may get this dialog and then when you dismiss it, the exception goes
up to the testing framework which handles it.

-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <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