|
Boost Users : |
From: Trevor Bain (trevor.bain_at_[hidden])
Date: 2008-08-01 16:41:32
Hello, I'm trying to just do the basic example of boost.test unit testing.
I'm getting compilation errors when I include the headers.
=============== test.cpp ====================
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
/*
#include <boost/test/unit_test_log.hpp>
#include <boost/test/unit_test_log_formatter.hpp>
*/
int add( int i, int j ) { return i+j; }
/* commented out
BOOST_AUTO_TEST_CASE( my_test ) {
// 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
}
*/
int main() { return 0; };
=============== test.cpp ====================
To compile I'm doing (I have to add the location of boost to the
include path with -I):
g++ -I/Users/zara/Programming/polyneuron/lib/boost_1_35_0/ test.cpp
The only output is:
Undefined symbols:
"vtable for boost::unit_test::unit_test_log_t", referenced from:
__ZTVN5boost9unit_test15unit_test_log_tE$non_lazy_ptr in ccDfKOkF.o
"boost::unit_test::framework::master_test_suite()", referenced from:
init_unit_test_suite(int, char**)in ccDfKOkF.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Which is a virtual function issue ... but why should I be having this
in a library I'm using?
I shouldn't have to touch the lib code ... what's up?
Do I need to implement some virtual function/class?
With the code uncommented I get many more errors - and this is the example code
given in the docs ...
Help is much appreciated.
- trevor
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