提高可定制入口点:定制main()

时间:2018-09-22 22:21:09

标签: c++ boost

我正在尝试在https://www.boost.org/doc/libs/1_68_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations/entry_point.html之后使用main()创建自定义boost::unit_test

MyClass.h定义了一个具有简单功能class的{​​{1}} MyClass

现在在`test_MainClass.cpp中:

add(x,y)

#define BOOST_TEST_DYN_LINK #include <boost/test/included/unit_test.hpp> #include "MyClass.h" BOOST_AUTO_TEST_CASE(constructor_test) { MyClass ms; BOOST_CHECK_EQUAL(ms.add(2, 3), 8); system("pause"); }

my_main.cpp

这会带来很多错误:

#define BOOST_TEST_MODULE test my_main
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_NO_MAIN
#include <boost/test/included/unit_test.hpp>

// entry point:
int main(int argc, char* argv[], char* envp[])
{
    return boost::unit_test::unit_test_main(&init_unit_test, argc, argv);

}

0 个答案:

没有答案