mardi 28 juin 2016

c++ BOOST_TEST not in scope

I'm using boost version 1.58

Boost appears to be installed correctly, and the following code compiles and runs correctly (giving an error on the third check):

#define BOOST_TEST_MODULE basics_test

#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE( basics_test ) {
  BOOST_CHECK(1 == 1);
  BOOST_CHECK(1 + 2 < 4);
  BOOST_CHECK(1 == 2);
}

However, when I attempt to run the second example from the site http://ift.tt/296n6CM, I get the error:

test.cpp: In member function ‘void test_op_reportings::test_method()’:
test.cpp:20:20: error: ‘BOOST_TEST’ was not declared in this scope
   BOOST_TEST(a == b);

When I change each instance of BOOST_TEST to BOOST_CHECK, the code compiles and runs normally. I'm using g++; when I configure g++ to use c++11 as in g++ -std=c++11 test cpp -o main I get the same error.

How should I go about fixing this?

Aucun commentaire:

Enregistrer un commentaire