rollbear / trompeloeil

Header only C++14 mocking framework
Boost Software License 1.0
802 stars 85 forks source link

Documentation, typo and missing bits and bobs #314

Closed parrotrueper closed 10 months ago

parrotrueper commented 11 months ago

In the Cookbook.md file, section for mocking free functions, in the example header, it needs the test framework header and the trompeloeil header. So it needs to change from this

// unit-test-C-API.h

#include "C-API.h"

class API
: 
:

to this (catch2 example)

// unit-test-C-API.h

#include <catch2/catch_test_macros.hpp>
#include <catch2/trompeloeil.hpp> /* this should go last */

#include "C-API.h"

class API
: 
:

Then in the c file there is a typo:

// unit-test_c_api.cpp
#include "unit-test-C-API.h"

API c_api_mock;

extern "C" {
  c_api_cookie c_api_init()
  {
    return api_mock.c_api_init();     // <----- here it should be c_api_mock instead of api_mock
  }

  int c_api_func1(c_api_cookie* cookie, const char* str, size_t len)
  {
    return api_mock.c_api_func1(cookie, str, len);    // <----- here it should be c_api_mock instead of api_mock
  }

  void c_api_end(c_api_cookie* cookie)
  {
    api_mock.c_api_end(cookie);    // <----- here it should be c_api_mock instead of api_mock
  }
}
rollbear commented 11 months ago

Awesome catch. Thanks. Would you mind making a pull request, or maybe one for each issue?

parrotrueper commented 11 months ago

done

rollbear commented 10 months ago

Tagged release, so closing now. Thanks again.