3

I'm trying to figure out how to use the Trompeloeil library with C++11. With this example, I've run into a huge amount of build errors, and I can't understand why.

#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);
  }
}

There are a massive amount of build errors, but the ones that stand out to me are the following:

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(   

as well as

/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");

If somebody could help me make sense of these, it'd be much appreciated. I can provide the full build errors on request

arved
  • 4,401
  • 4
  • 30
  • 53
MightyDodongo
  • 101
  • 1
  • 4

1 Answers1

0

Do you use C++ 11? Why do you use REQUIRE_CALL_V?

In fact you are using the C++14 syntax with the C++11 macro.

See https://github.com/rollbear/trompeloeil/blob/main/docs/Backward.md/#cxx11_require_call for details.

So if you use C++14, change to REQUIRE_CALL. If you are forced to use C++11, it looks like the RETURN(1) needs to be an argument to REQUIRE_CALL_V

arved
  • 4,401
  • 4
  • 30
  • 53