gpt4 book ai didi

c++ - 在 Visual Studio 中使用增强测试

转载 作者:可可西里 更新时间:2023-11-01 16:26:10 29 4
gpt4 key购买 nike

我正在尝试使用 Boost Test 为我的代码添加一些急需的单元测试。但是我似乎无法让它工作。现在我有以下代码

#include <Drawing.h>
#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_MODULE DrawingModelTests
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(DrawingModelTests)

BOOST_AUTO_TEST_CASE ( DrawingConstructorTest)
{
Drawing * drawing = new Drawing;

delete drawing;
}

BOOST_AUTO_TEST_SUITE_END()

据我了解,我不需要放置主电源或任何东西,因为 boost 会自己处理。但是 Visual Studio 一直给我一个“必须定义入口点”的错误。我是否需要手动添加到静态库的链接或其他内容?我正在编译为标准的 .exe 控制台应用程序。

最佳答案

将/SUBSYSTEM:CONSOLE 添加到链接器标志。在项目设置中,这是在 Linker->System 页面上。您可以将 boost 用作动态或静态库。

关于c++ - 在 Visual Studio 中使用增强测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2069174/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com