boost test

来源:互联网 发布:第三方服务商淘宝客 编辑:程序博客网 时间:2024/05/22 06:42

http://www.ibm.com/developerworks/cn/aix/library/au-ctools1_boost/


http://www.boost.org/doc/libs/1_51_0/libs/test/doc/html/intro.html


1. Why did I get a linker error when compiling my test program?

 

Boost Test Library components provide several usage variants: to create a test program you can link with the one of the precompiled library variants or use single-header variant. For example, to use Unit Test Framework you may either include the <boost/test/unit_test.hpp> and link with libunit_test_framework.lib or you can include <boost/test/included/unit_test.hpp> , in which case you should not need to link with any precompiled component. Note also that you should strictly follow specification on initialization function in other case some compilers may produce linker error like this.

Unresolved external init_unit_test_suite(int, char**).

The reason for this error is that in your implementation you should specify second argument of init_unit_test_suite exactly as in the specification, i.e.: char* [].

 2. for

add the below in the front of your code

> > #define BOOST_TEST_DYN_LINK
> > and
> > #define BOOST_TEST_MODULE MyTest

codes like: #include <...>


and compile with $g++ -Wall xxx.cpp -lboost_unit_test_framework

refer to test_boost_suit.cpp and sample1.cpp in develop/boost/unit_test/ in ubuntu

原创粉丝点击