c++ - 如何使用 boost::test 设置 C++ turtle 模拟库?

标签 c++ unit-testing boost turtle-mock

我正在尝试设置 turtle-mock带有 boost::test 框架的库。

我不知道该怎么做,文档中也没有提及...

我试图简单地将库源代码复制到 boost/include 中。 我还尝试将 turtle 目录复制到我的项目中,然后添加指向 turtle 文件夹的 CMake INCLUDE_DIRECTORIES 指令。

我只是想包括乌龟...

#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <boost/turtle/mock.hpp>

然后我得到这个错误:

In file included from /home/ferdi/boost/include/boost/turtle/detail/function.hpp:97:0,
             from /home/ferdi/boost/include/boost/turtle/detail/functor.hpp:13,
             from /home/ferdi/boost/include/boost/turtle/reset.hpp:15,
             from /home/ferdi/boost/include/boost/turtle/mock.hpp:14,
             from /home/ferdi/inesm/test/Test.hpp:7,
             from /home/ferdi/inesm/test/lib/inesm/component/note/TestNote.cpp:6:
/home/ferdi/boost/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52:37: fatal error: turtle/detail/function_iterate.hpp: Aucun fichier ou dossier de ce type
#        include BOOST_PP_FILENAME_1

("Aucun fichier ou dossier de ce type"意思是 "没有这种类型的文件或目录")

这是什么意思? 我该怎么办?

谢谢!

最佳答案

来自 the documentation典型的用法是

#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <turtle/mock.hpp>

或根据您的用例进行调整

#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <turtle/mock.hpp>

所以当包含 turtle 时没有 boost/。

我认为您不应该将 turtle 移动到 boost 中,而是将它分开并添加您所指的 CMake include 目录(但添加到 turtle 的父目录)。

如果您坚持将 turtle 与 boost 合并,您可以尝试使用 turtle aka Boost.Mock 的“boost ”版本.

关于c++ - 如何使用 boost::test 设置 C++ turtle 模拟库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26486806/

相关文章:

c++ - 如何使用 boost::function_types::parameter_types 与 ClassTypeTransform

boost Asio message_flags

c++ - 将 strncpy 放入一个没有空终止符空间的字符串中是否安全?

c++ - 使用openCV去除二值图像中的噪声

c++ - 如何防止 GTK 按钮中的鼠标悬停效果

r - covr 显示 0% 的覆盖率,而所有带有 testthat 的测试都通过了

c++ - 使用 ICC 的 Linux 中对 clock_gettime() 的 undefined reference

unit-testing - 如何以编程方式关闭 ExpressJS 的实例?

python - 使用 WebTest 对 Bottle 应用程序进行单元测试

c++ - 寻找 boost::iterator_facade 的示例用法