Skip to content

Commit

Permalink
Generated single header files.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Mar 20, 2021
1 parent 143d2f6 commit e40bc46
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 208 deletions.
40 changes: 22 additions & 18 deletions single_header/boost/fakeit.hpp
Expand Up @@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2019-06-01 12:14:40.033003
* Generated: 2021-03-20 16:12:25.783748
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
Expand Down Expand Up @@ -5247,6 +5247,7 @@ namespace fakeit {
namespace fakeit {

template<typename TARGET, typename SOURCE>
[[gnu::optimize("no-devirtualize")]]
TARGET union_cast(SOURCE source) {

union {
Expand All @@ -5268,12 +5269,15 @@ namespace fakeit {
class VTUtils {
public:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#pragma GCC diagnostic pop

template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
Expand Down Expand Up @@ -6131,31 +6135,31 @@ namespace fakeit {

template<int N>
struct apply_func {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple(f, t, std::get<N - 1>(t), args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple<R>(std::forward<FunctionType>(f), t, std::get<N - 1>(t), args...);
}
};

template<>
struct apply_func < 0 > {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> & , Args &... args) {
return f(args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> & , Args &... args) {
return std::forward<FunctionType>(f)(args...);
}
};

struct TupleDispatcher {

template<typename R, typename ... ArgsF, typename ... ArgsT>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple(f, t);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple<R>(std::forward<FunctionType>(f), t);
}

template<typename R, typename ...arglist>
static R invoke(std::function<R(arglist &...)> func, const std::tuple<arglist...> &arguments) {
template<typename R, typename ...arglist, typename FunctionType>
static R invoke(FunctionType&& func, const std::tuple<arglist...> &arguments) {
std::tuple<arglist...> &args = const_cast<std::tuple<arglist...> &>(arguments);
return applyTuple(func, args);
return applyTuple<R>(std::forward<FunctionType>(func), args);
}

template<typename TupleType, typename FunctionType>
Expand Down Expand Up @@ -9296,7 +9300,7 @@ namespace fakeit {
#endif

#define MOCK_TYPE(mock) \
std::remove_reference<decltype(mock.get())>::type
std::remove_reference<decltype((mock).get())>::type

#define OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
Expand All @@ -9305,16 +9309,16 @@ namespace fakeit {
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)

#define Dtor(mock) \
mock.dtor().setMethodDetails(#mock,"destructor")
(mock).dtor().setMethodDetails(#mock,"destructor")

#define Method(mock, method) \
mock.template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)

#define OverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define ConstOverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define Verify(...) \
Verify( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
Expand Down
30 changes: 17 additions & 13 deletions single_header/catch/fakeit.hpp
Expand Up @@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2019-11-19 16:36:52.128738
* Generated: 2021-03-20 16:12:25.865246
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
Expand Down Expand Up @@ -5321,6 +5321,7 @@ namespace fakeit {
namespace fakeit {

template<typename TARGET, typename SOURCE>
[[gnu::optimize("no-devirtualize")]]
TARGET union_cast(SOURCE source) {

union {
Expand All @@ -5342,12 +5343,15 @@ namespace fakeit {
class VTUtils {
public:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#pragma GCC diagnostic pop

template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
Expand Down Expand Up @@ -6205,31 +6209,31 @@ namespace fakeit {

template<int N>
struct apply_func {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple(f, t, std::get<N - 1>(t), args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple<R>(std::forward<FunctionType>(f), t, std::get<N - 1>(t), args...);
}
};

template<>
struct apply_func < 0 > {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> & , Args &... args) {
return f(args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> & , Args &... args) {
return std::forward<FunctionType>(f)(args...);
}
};

struct TupleDispatcher {

template<typename R, typename ... ArgsF, typename ... ArgsT>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple(f, t);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple<R>(std::forward<FunctionType>(f), t);
}

template<typename R, typename ...arglist>
static R invoke(std::function<R(arglist &...)> func, const std::tuple<arglist...> &arguments) {
template<typename R, typename ...arglist, typename FunctionType>
static R invoke(FunctionType&& func, const std::tuple<arglist...> &arguments) {
std::tuple<arglist...> &args = const_cast<std::tuple<arglist...> &>(arguments);
return applyTuple(func, args);
return applyTuple<R>(std::forward<FunctionType>(func), args);
}

template<typename TupleType, typename FunctionType>
Expand Down
41 changes: 22 additions & 19 deletions single_header/cute/fakeit.hpp
Expand Up @@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2019-10-18 14:29:08.645463
* Generated: 2021-03-20 16:12:25.944745
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
Expand Down Expand Up @@ -1135,7 +1135,6 @@ namespace fakeit {
virtual void handle(const SequenceVerificationEvent &evt) override {
std::string format(_formatter.format(evt));
throw cute::test_failure(format, evt.file(), evt.line());

}

virtual void handle(const NoMoreInvocationsVerificationEvent &evt) override {
Expand Down Expand Up @@ -5212,6 +5211,7 @@ namespace fakeit {
namespace fakeit {

template<typename TARGET, typename SOURCE>
[[gnu::optimize("no-devirtualize")]]
TARGET union_cast(SOURCE source) {

union {
Expand All @@ -5233,12 +5233,15 @@ namespace fakeit {
class VTUtils {
public:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#pragma GCC diagnostic pop

template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
Expand Down Expand Up @@ -6096,31 +6099,31 @@ namespace fakeit {

template<int N>
struct apply_func {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple(f, t, std::get<N - 1>(t), args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple<R>(std::forward<FunctionType>(f), t, std::get<N - 1>(t), args...);
}
};

template<>
struct apply_func < 0 > {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> & , Args &... args) {
return f(args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> & , Args &... args) {
return std::forward<FunctionType>(f)(args...);
}
};

struct TupleDispatcher {

template<typename R, typename ... ArgsF, typename ... ArgsT>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple(f, t);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple<R>(std::forward<FunctionType>(f), t);
}

template<typename R, typename ...arglist>
static R invoke(std::function<R(arglist &...)> func, const std::tuple<arglist...> &arguments) {
template<typename R, typename ...arglist, typename FunctionType>
static R invoke(FunctionType&& func, const std::tuple<arglist...> &arguments) {
std::tuple<arglist...> &args = const_cast<std::tuple<arglist...> &>(arguments);
return applyTuple(func, args);
return applyTuple<R>(std::forward<FunctionType>(func), args);
}

template<typename TupleType, typename FunctionType>
Expand Down Expand Up @@ -9261,7 +9264,7 @@ namespace fakeit {
#endif

#define MOCK_TYPE(mock) \
std::remove_reference<decltype(mock.get())>::type
std::remove_reference<decltype((mock).get())>::type

#define OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
Expand All @@ -9270,16 +9273,16 @@ namespace fakeit {
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)

#define Dtor(mock) \
mock.dtor().setMethodDetails(#mock,"destructor")
(mock).dtor().setMethodDetails(#mock,"destructor")

#define Method(mock, method) \
mock.template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)

#define OverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define ConstOverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define Verify(...) \
Verify( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
Expand Down

0 comments on commit e40bc46

Please sign in to comment.