c – Boost :: Test的问题

c – Boost :: Test的问题,第1张

概述为什么这个(从 boost site复制)给我一个错误?!在VS 2010旗舰版: #include <boost\test\unit_test.hpp>#define BOOST_TEST_MODULE MyTestint add( int i, int j ) { return i+j; }BOOST_AUTO_TEST_CASE( my_test ){ // seve 为什么这个(从 boost site复制)给我一个错误?!在VS 2010旗舰版:

#include <boost\test\unit_test.hpp>#define BOOST_TEST_MODulE MyTestint add( int i,int j ) { return i+j; }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}

错误

Error   1   error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite@@YAPAVtest_suite@unit_test@boost@@HQAPAD@Z) referenced in function _main
解决方法 在包含标头之前尝试定义BOOST_TEST_MODulE. 总结

以上是内存溢出为你收集整理的c – Boost :: Test的问题全部内容,希望文章能够帮你解决c – Boost :: Test的问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1220436.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存