Boost.Test spits out garbage instead of readable error messages

151 Views Asked by At

I am using Boost.Test and my test fails. That's fun and all, but the results are horrifying. This is the output of Boost.Test:

$ zwja/Build/Products/Debug/test ; exit;                                     <
Running 2 test cases...
/Users/daknok/Desktop/libxxqlite/test/DatabaseTest.cpp:32: error in "P
                                                                      `??k??k
                                                                             ???k?%??k??k
         l
          p??k????k?": 
*** 1 failure detected in test suite "Master Test Suite"

Here is my failing test case:

BOOST_AUTO_TEST_CASE(Querying) {
  BOOST_CHECK_NO_THROW({
    XXQLite::Database db;
    XXQLite::Query query1 = db.createQuery("CREATE TABLE Foo (Id PRIMARY KEY)");
    XXQLite::Query query2
      = db.createQuery("SELECT * FROM Foo WHERE Id=? OR Id=? OR Id=?",
                       1, 2, 3);
  });
}

I really have no idea what's going on here. What could be the cause of these strange, unreadable error messages? Did Boost not like my code? Is there something wrong with my Boost installation?

3

There are 3 best solutions below

0
On

According to the example here, the thing between the question marks is what you passed to BOOST_AUTO_TEST_CASE:

BOOST_AUTO_TEST_CASE( test )
{
    BOOST_CHECK_NO_THROW( throw my_exception() );
}

Output:

Running 1 test case...
test.cpp(8): error in "test": exception thrown by throw my_exception()

That is, for you it should print "Querying". Anything going on with that name? Does it work if you change it to something else?

Also try looking at your preprocessor output. If you're using gcc, use the -E flag.

0
On

Firstly your code doesn't quite help you find which of the calls is throwing an exception or generally giving you grief. So I'd suggest instead something like

BOOST_AUTO_TEST_CASE(Querying) {
  XXQLite::Database db;
  XXQLite::Query query1;
  XXQLite::Query query2;
  BOOST_CHECK_NO_THROW(query1 = db.createQuery("CREATE TABLE Foo (Id PRIMARY KEY)");
  BOOST_CHECK_NO_THROW(query2 = db.createQuery("SELECT * FROM Foo WHERE Id=? OR Id=? OR Id=?", 1, 2, 3));
}

That way you'll have better luck finding out exactly what statement caused problems. It could be one of the declarations e.g. Database db, Query query1. It could be one of the calls db.createQuery.

1
On

It appears you have some kind of memory corruption. Do a clean build. Try valgrind. Try different boost release.