2010-12-06 3 views
1

boost.test을 부스트 1.33.1의 원격 시스템에서 사용하려고합니다.이전 버전의 boost.test에 문제가 발생했습니다.

#define BOOST_TEST_MODULE MyTest 
#include <boost/test/included/unit_test.hpp> // I've changed here 

int add(int i, int j) { return i+j; } 

BOOST_AUTO_TEST_CASE(my_test) // <--- line 7 
{ 
// seven ways to detect and report the same error: 
BOOST_CHECK(add(2,2) == 4);  // #1 continues on error 

BOOST_REQUIRE(add(2,2) == 4);  // #2 throws on error 

if(add(2,2) != 4) 
    BOOST_ERROR("Ouch...");   // #3 continues on error 

if(add(2,2) != 4) 
    BOOST_FAIL("Ouch...");    // #4 throws on error 

if(add(2,2) != 4) throw "Ouch..."; // #5 throws on error 

BOOST_CHECK_MESSAGE(add(2,2) == 4, // #6 continues on error 
        "add(..) result: " << add(2,2)); 

BOOST_CHECK_EQUAL(add(2,2), 4); // #7 continues on error 
} 

을하지만 원격 시스템의 파일 unit_test.hpp가 존재하지 않습니다 : 내 PC에 http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/tutorials/hello-the-testing-world.html에서이 작은 예를 작동합니다. 내 컴퓨터에서 파일 unit_test_framework.hpp은 간단히 :

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

이며 주 시스템에 있습니다. 그래서가 포함 변경 시도 :

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

하지만 컴파일러는 말한다 :

main.cpp:7: error: expected constructor, destructor, or type conversion before ‘(’ token 

이 무엇입니까? 그것을 해결하는 방법?

+0

어떤 시스템에서 포함? –

+0

원격 시스템에 어떤 버전의 부스트가 설치되어 있는지 알려주십시오. – jopasserat

+0

remote : 1.33.1, local : 1.36.0 –

답변

3

#define BOOST_AUTO_TEST_MAIN 

또는 당신은 링커 오류가 발생합니다

0

부스트 버전이 1.33보다 오래된 경우 BOOST_AUTO_TEST_CASE에서 BOOST_AUTO_UNIT_TEST으로 이름을 변경해야하며 새로운 버전의 부스트에서 컴파일을 중단해서는 안됩니다.

이 Boost.Test 1.33 Release Notes 참조 :

BOOST_AUTO_UNIT_TEST이 BOOST_AUTO_TEST_CASE로 변경. 이전 이름은 여전히 ​​ 이지만 더 이상 사용되지 않음

+0

나는 똑같은 메시지를 전했다. 나는'BOOST_AUTO_TEST_CASE'가'boost/test/auto_unit_test.hpp'에 정의되어 있다고 생각합니다. 하지만 그것을 포함 시키면 다음과 같은 결과를 얻습니다.''init_unit_test_suite (int, char **) '에 대한 정의되지 않은 참조' –

+0

@wiso :'undefined reference'는 실제로 매우 다른 오류입니다! boost.test 라이브러리에 링크해야합니다. – icecrime

+1

이미'-lboost_unit_test_framework'를 사용하고 있는데, 무엇을 연결해야합니까? –

0

대상 플랫폼의 부스트 버전은 무엇입니까? 거기에 이전 버전을 사용하고 있습니까?

boost.test (boost/test/included/unit_test.hpp 헤더를 포함하고 boost/test/unit_test.hpp는 포함하지 않음)의 헤더 전용 버전을 사용하고 있으므로, PC에서 대상 컴퓨터로 설치하고 컴파일러에게 사용하도록 지시합니까?

대신에
#include <boost/test/auto_unit_test.hpp> 

:

#include <boost/test/unit_test.hpp> 

또한의 #include 추가하기 전에 : 부스트 1.33 사용에

관련 문제