gpt4 book ai didi

c++ - 无法设置执行上下文以运行测试

转载 作者:行者123 更新时间:2023-11-30 05:22:02 24 4
gpt4 key购买 nike

这是我当前的设置:

  • 我有一组完美运行的单元测试
  • 我有一组库都编译为静态 .lib
  • 单元测试项目被编译为.dll 并包含一些类

我最近添加了一个类,即MyCoolClass.h:

#include "AnotherBoringClass.h" // also inherits from BoringClass

class SuperCoolClass: public BoringClass
{
/*
* My super cool implementation
*/
protected:
std::shared_ptr<AnotherBoringClass> myCoolPointer;
}

一切正常,编译等等。但是当我尝试添加单元测试时:

#include "CppUnitTest.h"
#include "MyCoolClass.h"

TEST_CLASS(MyTestClass)
{
public:
/*
* Bunch of super cool -working- tests
*/
TEST_METHOD(MyBrokenTest)
{
auto myVar = std::make_shared<MyCoolClass>(); // as soon as I comment this line everything works!!!
}
}

当我如上评论该行时,一切正常!我做错了什么?

我尝试过的:

  • This ,但我将所有内容都放在同一个输出文件夹中。此外,我使用了 QuantLib 和 Boost,但所有其他单元测试都运行良好

  • Same as previous link

提前致谢!

最佳答案

经过千辛万苦的解决,终于搞定了。这是因为我使用的是静态链接的 MKL,而我的程序是使用选项 Property -> C/C++ -> Code Generation -> Runtime Library -> xxx DLL 编译的。

希望对您有所帮助!

关于c++ - 无法设置执行上下文以运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39859808/

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