2

我试图弄清楚如何将 Trompeloeil 库与 C++11 一起使用。在这个例子中,我遇到了大量的构建错误,我不明白为什么。

#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <rapidcheck.h>
#include <rapidcheck/state.h>
#include <trompeloeil.hpp>
#include "../../../include/Orion.h"
#include "../../../include/optionCheckerFileHandler.h"

class mock{
  public:
  MAKE_MOCK1(getFileParams, int(int));
};

TEST_CASE( "Factorials are computed", "[factorial]" ) {
  using trompeloeil::_;  // wild card for matching any value
  using trompeloeil::gt; // greater-than match
  mock m;{
    REQUIRE_CALL_V(m, getFileParams(1)).RETURN(0);
  }
}

有大量的构建错误,但对我来说突出的错误如下:

In file included from /home/adny/tortoiseSoftworks/software/gamedev/tortoiseGamedev/test/testing/src/main.cpp:5:0:
/home/adny/tortoiseSoftworks/software/gamedev/tortoiseGamedev/test/testing/src/main.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____0()’:
/home/adny/tortoiseSoftworks/software/gamedev/tortoiseGamedev/test/testing/lib/trompeloeil/include/trompeloeil.hpp:4727:3: error: ‘class std::unique_ptr<trompeloeil::expectation>’ has no member named ‘handle_return’
   handle_return(   

/home/adny/tortoiseSoftworks/software/gamedev/tortoiseGamedev/test/testing/lib/trompeloeil/include/trompeloeil.hpp:3891:7: error: static assertion failed: RETURN missing for non-void function
       static_assert(valid_return_type, "RETURN missing for non-void function");

如果有人可以帮助我理解这些,将不胜感激。我可以根据要求提供完整的构建错误

4

1 回答 1

0

你使用 C++ 11 吗?你为什么用REQUIRE_CALL_V

实际上,您正在使用 C++14 语法和 C++11 宏。

有关详细信息,请参阅https://github.com/rollbear/trompeloeil/blob/main/docs/Backward.md/#cxx11_require_call

因此,如果您使用 C++14,请更改为REQUIRE_CALL. 如果您被迫使用 C++11,看起来 RETURN(1) 需要作为参数REQUIRE_CALL_V

于 2022-02-21T11:01:30.603 回答