Boost logo

Boost Users :

Subject: [Boost-users] First attempt at using Boost::Test is a flop: the program ends with an exception related to std::string but I don't use any
From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2012-05-20 23:50:22


Here is the full output from my program:

 

$ ./decision.test.suite

terminate called after throwing an instance of 'std::logic_error'

  what(): basic_string::_S_construct NULL not valid

Aborted (core dumped)

 

Now, all the code in this program is focussed on number crunching, so none
of it involves strings. I am guessing that I missed something in setting up
a test suite.

 

After including the headers for the function objects being tested (some of
which are template classes) as well as headers for several boost libraries,
I have the following:

 

 

#define BOOST_TEST_MAIN decision_tests

#include <boost/test/unit_test.hpp>

#include <boost/test/floating_point_comparison.hpp>

 

BOOST_AUTO_TEST_SUITE( test_decisions )

 

BOOST_AUTO_TEST_CASE( test_dist_moments ) {

 

And I have a series of test cases that start the same way.

 

After setting up the required data for each test, I use something like:

 

    BOOST_CHECK_CLOSE( Sm, 0.00000000000, 0.0001 );

 

or something like:

 

  BOOST_CHECK(ibll(x1,i) == true);

  

Of course each test case ends with a closing '}' and the whole program ends
with:

 

BOOST_AUTO_TEST_SUITE_END()

 

Now, I know I can write a suite of unit tests without using Boost::Test, but
I was hoping I'd just missed something obvious. I don't even know where to
look for the cause of this exception since none of the code I actually wrote
that is involved in these tests makes any use at all of any strings.

 

My guess is that I must have missed some macro required by the unit test
framework that is required in order to ensure whatever string object is
involved in this exception doesn't get a NULL value. Or maybe I missed a
header. I really have no idea where to look for the cause of this problem.

 

Any guidance on what to look for or what I may have missed, would be greatly
appreciated.

 

Cheers

 

Ted

 



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