From: Philippe Coval Date: Mon, 5 Sep 2016 12:58:29 +0000 (+0200) Subject: hippomocks: Import sources from upstream X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91317819cd385b0b506cefacd93c9aba244f3aa2;p=contrib%2Fiotivity.git hippomocks: Import sources from upstream From: https://github.com/dascandy/hippomocks/archive/8e210c5808d490b26fff69151c801fa28d291fcb.zip It is strongly recommended to rely on scons instead, if not possible, this change workaround this. For more details about building IoTivity please check: https://wiki.iotivity.org/build Bug: https://jira.iotivity.org/browse/IOT-820 Bug-Tizen: https://bugs.tizen.org/jira/browse/TINF-861 Change-Id: Ibfddc7be509ec992bfaa7a7bf6759a12b56a9f02 Origin: https://gerrit.iotivity.org/gerrit/#/c/11747/ Signed-off-by: Philippe Coval --- diff --git a/extlibs/hippomocks-master/.gitignore b/extlibs/hippomocks-master/.gitignore new file mode 100644 index 0000000..5bbaab6 --- /dev/null +++ b/extlibs/hippomocks-master/.gitignore @@ -0,0 +1,6 @@ +*.d +*.o +*.exe + +*.user +*.bak diff --git a/extlibs/hippomocks-master/.travis.yml b/extlibs/hippomocks-master/.travis.yml new file mode 100644 index 0000000..6084d99 --- /dev/null +++ b/extlibs/hippomocks-master/.travis.yml @@ -0,0 +1,22 @@ +language: cpp +compiler: +- clang +- gcc +script: +- make && make test + +env: + global: + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "Jt0baUgI9mwbUptf+4NpYJREp7s2YfDj+jH7e9ZTAdriuN6h8Qwtd+tHjIusAG5iO4wecHOh8kOxlDvqTAn6YiXnHELhJieNxFIFwUlyfwYpnNMF41JpO5nsvyffu/xSJHw1hUpJ5xJDOKOBAQ1UBR42gM56hJfyjRE8zoKxM0s=" + +addons: + coverity_scan: + project: + name: "dascandy/hippomocks" + description: "HippoMocks, C++98 Mocking Framework" + notification_email: dascandy@gmail.com + build_command: make && make test + branch_pattern: master + diff --git a/extlibs/hippomocks-master/CMakeLists.txt b/extlibs/hippomocks-master/CMakeLists.txt new file mode 100644 index 0000000..64f40c4 --- /dev/null +++ b/extlibs/hippomocks-master/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0) +enable_testing() + +if (NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-long-long -std=c++11") +endif() + +add_subdirectory(HippoMocksTest) + +install(FILES ${PROJECT_SOURCE_DIR}/HippoMocks/hippomocks.h + DESTINATION include/) diff --git a/extlibs/hippomocks-master/HippoMocks/comsupport.h b/extlibs/hippomocks-master/HippoMocks/comsupport.h new file mode 100644 index 0000000..fe2f0f0 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocks/comsupport.h @@ -0,0 +1,42 @@ +#pragma once + +#ifdef _MSC_VER +#include +#include + +template +void AddComExpectations(HM_NS MockRepository& mocks, T* m) +{ + mocks.OnCall(m, T::AddRef) + .Return(1); + mocks.OnCall(m, T::Release) + .Return(1); + mocks.OnCall(m, T::QueryInterface) + .With(__uuidof(T), Out((void**)m)) + .Return(S_OK); + + mocks.OnCall(m, T::QueryInterface) + .With(__uuidof(IUnknown), Out((void**)m)) + .Return(S_OK); + +} + +template +void ConnectComInterfaces(HM_NS MockRepository& mocks, T1* m1, T2* m2) +{ + //from T1 to T2 + mocks.OnCall(m1, T1::QueryInterface) + .With(__uuidof(T2), Out((void**)m2)) + .Return(S_OK); + //from T2 to T1 + mocks.OnCall(m2, T2::QueryInterface) + .With(__uuidof(T1), Out((void**)m1)) + .Return(S_OK); + + AddComExpectations(mocks, m1); + AddComExpectations(mocks, m2); + + //no support for interface hierarchies + //no Base IUnknown -> do it yourself if you really need that special case +} +#endif \ No newline at end of file diff --git a/extlibs/hippomocks-master/HippoMocks/hippomocks.h b/extlibs/hippomocks-master/HippoMocks/hippomocks.h new file mode 100644 index 0000000..8b88af3 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocks/hippomocks.h @@ -0,0 +1,6350 @@ +// HippoMocks, a library for using mocks in unit testing of C++ code. +// Copyright (C) 2008, Bas van Tiel, Christian Rexwinkel, Mike Looijmans, +// Peter Bindels +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +// You can also retrieve it from http://www.gnu.org/licenses/lgpl-2.1.html + +#ifndef HIPPOMOCKS_H +#define HIPPOMOCKS_H + +// If you want to put all HippoMocks symbols into the global namespace, use the define below. +//#define NO_HIPPOMOCKS_NAMESPACE + +// The DEFAULT_AUTOEXPECT is an option that determines whether tests are, by default, under- or +// overspecified. Auto-expect, by function, adds an expectation to the current ExpectCall that +// it will happen after the previous ExpectCall. For many people this is an intuitive and logical +// thing when writing a C++ program. Usually, this makes your test workable but overspecified. +// Overspecified means that your test will fail on working code that does things in a different +// order. The alternative, underspecified, allows code to pass your test that does things in a +// different order, where that different order should be considered wrong. Consider reading a +// file, where it needs to be first opened, then read and then closed. +// +// The default is to make tests overspecified. At least it prevents faulty code from passing +// unit tests. To locally disable (or enable) this behaviour, set the boolean autoExpect on your +// MockRepository to false (or true). To globally override, redefine DEFAULT_AUTOEXPECT to false. +#ifndef DEFAULT_AUTOEXPECT +#define DEFAULT_AUTOEXPECT true +#endif + +#ifdef NO_HIPPOMOCKS_NAMESPACE +#define HM_NS +#else +#define HM_NS HippoMocks:: +#endif + +#ifdef _MSC_VER +#ifdef _WIN64 +#define WINCALL +#else +#define WINCALL __stdcall +#endif +#endif +#ifndef DEBUGBREAK +#ifdef _MSC_VER +extern "C" __declspec(dllimport) int WINCALL IsDebuggerPresent(); +extern "C" __declspec(dllimport) void WINCALL DebugBreak(); +#define DEBUGBREAK(e) if (IsDebuggerPresent()) DebugBreak(); else (void)0 +#else +#define DEBUGBREAK(e) +#endif +#endif + +#ifndef DONTCARE_NAME +#define DONTCARE_NAME _ +#endif + +#ifndef VIRT_FUNC_LIMIT +#define VIRT_FUNC_LIMIT 1024 +#elif VIRT_FUNC_LIMIT > 1024 +#error Adjust the code to support more than 1024 virtual functions before setting the VIRT_FUNC_LIMIT above 1024 +#endif + +#ifdef __GNUC__ +#define EXTRA_DESTRUCTOR +#endif + +#ifdef __EDG__ +#define FUNCTION_BASE 3 +#define FUNCTION_STRIDE 2 +#else +#define FUNCTION_BASE 0 +#define FUNCTION_STRIDE 1 +#endif + +#if defined(_M_IX86) || defined(__i386__) || defined(i386) || defined(_X86_) || defined(__THW_INTEL) || defined(__x86_64__) || defined(_M_X64) +#define SOME_X86 +#elif defined(arm) || defined(__arm__) || defined(ARM) || defined(_ARM_) || defined(__aarch64__) +#define SOME_ARM +#endif + +#if defined(__x86_64__) || defined(_M_X64) +#define CMOCK_FUNC_PLATFORMIS64BIT +#endif + +#ifdef SOME_X86 +#if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) +#define _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#elif defined(__linux__) && defined(__GNUC__) +#define _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#elif defined(__APPLE__) +#define _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#endif +#elif defined(SOME_ARM) && defined(__GNUC__) +#define _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + +// This clear-cache is *required*. The tests will fail if you remove it. +extern "C" void __clear_cache(char *beg, char *end); +#endif + +#if defined(__GNUC__) && !defined(__EXCEPTIONS) +#define HM_NO_EXCEPTIONS +class X{}; +#define BASE_EXCEPTION X +#else +#ifndef BASE_EXCEPTION +#define BASE_EXCEPTION std::exception +#include +#endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +// these warnings are pointless and huge, and will confuse new users. +#pragma warning(push) +// If you can't generate an assignment operator the least you can do is shut up. +#pragma warning(disable: 4512) +// Alignment not right in a union? +#pragma warning(disable: 4121) +// No deprecated warnings on functions that really aren't deprecated at all. +#pragma warning(disable: 4996) + +// Tell Microsoft to conform to C++ (as far as is possible...) +#pragma pointers_to_members(full_generality, virtual_inheritance) +#endif + +#ifndef NO_HIPPOMOCKS_NAMESPACE +namespace HippoMocks +{ +#endif + +//Type-safe exception wrapping +class ExceptionHolder +{ +public: + virtual ~ExceptionHolder() {} + virtual void rethrow() = 0; + template + static ExceptionHolder *Create(T ex); +}; + +template +class ExceptionWrapper : public ExceptionHolder { + T exception; +public: + ExceptionWrapper(T ex) : exception(ex) {} + void rethrow() { throw exception; } +}; + +template +ExceptionHolder *ExceptionHolder::Create(T ex) +{ + return new ExceptionWrapper(ex); +} + +#ifdef HM_NO_EXCEPTIONS +#define RAISEEXCEPTION(e) { std::string err = e.what(); DEBUGBREAK(e); printf("Mock error found - Fatal due to no exception support:\n"); \ + printf("%s\n", err.c_str()); \ + abort(); exit(-1); } +#define RAISELATENTEXCEPTION(e) { std::string err = e.what(); DEBUGBREAK(e); printf("Mock error found - Fatal due to no exception support:\n"); \ + printf("%s\n", err.c_str()); \ + abort(); exit(-1); } +#else +#define RAISEEXCEPTION(e) { DEBUGBREAK(e); throw e; } +#define RAISELATENTEXCEPTION(e) { DEBUGBREAK(e); if (std::uncaught_exception()) \ + MockRepoInstanceHolder<0>::instance->SetLatentException(ExceptionHolder::Create(e)); \ + else throw e; } +#endif + +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#include + +#if defined(_WIN32) +#ifndef NO_HIPPOMOCKS_NAMESPACE +} +#endif + +// De-windows.h-ified import to avoid including that file. +#ifdef _WIN64 +extern "C" __declspec(dllimport) int WINCALL VirtualProtect(void *func, unsigned long long byteCount, unsigned long flags, unsigned long *oldFlags); +#else +extern "C" __declspec(dllimport) int WINCALL VirtualProtect(void *func, unsigned long byteCount, unsigned long flags, unsigned long *oldFlags); +#endif + +#ifndef PAGE_EXECUTE_READWRITE +#define PAGE_EXECUTE_READWRITE 0x40 +#endif + +#ifndef NO_HIPPOMOCKS_NAMESPACE +namespace HippoMocks { +#endif + +class Unprotect +{ +public: + Unprotect(void *location, size_t byteCount) + : origFunc(location) + , byteCount(byteCount) + { + VirtualProtect(origFunc, byteCount, PAGE_EXECUTE_READWRITE, &oldprotect); + } + ~Unprotect() + { + unsigned long dontcare; + VirtualProtect(origFunc, byteCount, oldprotect, &dontcare); + } +private: + void *origFunc; + size_t byteCount; + unsigned long oldprotect; +}; +#else +#include +#include + +class Unprotect +{ +public: + Unprotect(void *location, size_t count) + : origFunc((intptr_t)location & (~0xFFF)) + , byteCount(count + ((intptr_t)location - origFunc)) + { + mprotect((void *)origFunc, this->byteCount, PROT_READ|PROT_WRITE|PROT_EXEC); + }; + ~Unprotect() + { + mprotect((void *)origFunc, byteCount, PROT_READ|PROT_EXEC); + } +private: + intptr_t origFunc; + int byteCount; +}; +#endif + +typedef unsigned int e9ptrsize_t; + +template +T horrible_cast(U u) +{ + union { T t; U u; } un; + un.u = u; + return un.t; +} + +class Replace +{ +private: + void *origFunc; + char backupData[16]; // typical use is 5 for 32-bit and 14 for 64-bit code. +public: + template + Replace(T funcptr, T replacement) + : origFunc(horrible_cast(funcptr)) + { + Unprotect _allow_write(origFunc, sizeof(backupData)); + memcpy(backupData, origFunc, sizeof(backupData)); +#ifdef SOME_X86 +#ifdef CMOCK_FUNC_PLATFORMIS64BIT + if (llabs((long long)origFunc - (long long)replacement) < 0x80000000LL) { +#endif + *(unsigned char *)origFunc = 0xE9; + *(e9ptrsize_t*)(horrible_cast(origFunc) + 1) = (e9ptrsize_t)(horrible_cast(replacement) - horrible_cast(origFunc) - sizeof(e9ptrsize_t) - 1); +#ifdef CMOCK_FUNC_PLATFORMIS64BIT + } else { + unsigned char *func = (unsigned char *)origFunc; + func[0] = 0xFF; // jmp (rip + imm32) + func[1] = 0x25; + func[2] = 0x00; // imm32 of 0, so immediately after the instruction + func[3] = 0x00; + func[4] = 0x00; + func[5] = 0x00; + *(long long*)(horrible_cast(origFunc) + 6) = (long long)(horrible_cast(replacement)); + } +#endif +#elif defined(SOME_ARM) + unsigned int *rawptr = (unsigned int *)((intptr_t)(origFunc) & (~3)); + if ((intptr_t)origFunc & 1) { + rawptr[0] = 0x6800A001; + rawptr[1] = 0x46874687; + rawptr[2] = (intptr_t)replacement; + } else { + rawptr[0] = 0xE59FF000; + rawptr[1] = (intptr_t)replacement; + rawptr[2] = (intptr_t)replacement; + } + __clear_cache((char *)rawptr, (char *)rawptr+16); +#endif + } + ~Replace() + { + Unprotect _allow_write(origFunc, sizeof(backupData)); + memcpy(origFunc, backupData, sizeof(backupData)); +#ifdef SOME_ARM + unsigned int *rawptr = (unsigned int *)((intptr_t)(origFunc) & (~3)); + __clear_cache((char *)rawptr, (char *)rawptr+16); +#endif + } +}; +#endif + +class MockRepository; + +struct +RegistrationType +{ + RegistrationType( unsigned min, unsigned max ) : minimum( min ), maximum( max ) {} + unsigned minimum; + unsigned maximum; +}; + +inline +bool operator==( RegistrationType const& rhs, RegistrationType const& lhs ) +{ + return rhs.minimum == lhs.minimum && rhs.maximum == lhs.maximum; +} + + +const RegistrationType Any = RegistrationType((std::numeric_limits::min)(), (std::numeric_limits::max)()); +const RegistrationType Never = RegistrationType((std::numeric_limits::min)(), (std::numeric_limits::min)()); +const RegistrationType Once = RegistrationType( 1, 1 ); + + + + +// base type +class base_mock { +public: + void destroy() { unwriteVft(); delete this; } + virtual ~base_mock() {} + void *rewriteVft(void *newVf) + { + void *oldVf = *(void **)this; + *(void **)this = newVf; + return oldVf; + } + void reset() + { + unwriteVft(); + mock_reset(); + } + virtual void mock_reset() = 0; + void unwriteVft() + { + *(void **)this = (*(void ***)this)[VIRT_FUNC_LIMIT+1]; + } +}; + +template +class ByRef +{ +public: + explicit ByRef(T &argument) : arg(argument) {} + void operator()() { arg(); } + T &arg; +}; + +template +ByRef byRef(T &arg) { + return ByRef(arg); +} + +class NullType +{ +public: + bool operator==(const NullType &) const + { + return true; + } +}; + +class DontCare { +private: + inline DontCare &Instance(); +}; +static DontCare DONTCARE_NAME; +inline DontCare &DontCare::Instance() +{ + return DONTCARE_NAME; +} + +template +struct OutParam: public DontCare +{ + explicit OutParam(T val): value(val) {} + T value; +}; + +template +OutParam Out(T t) { return OutParam(t); } + +template +struct InParam; + +template +struct InParam: public DontCare +{ + explicit InParam(T& val): value(val) + { + } + T& value; +}; + +template +struct InParam: public DontCare +{ + explicit InParam(T*& val): value(val) + { + } + T*& value; +}; + +template +InParam In(T& t) { return InParam(t); } + +template +InParam In(T*& t) { return InParam(t); } + +struct NotPrintable { template NotPrintable(T const&) {} }; + +inline std::ostream &operator<<(std::ostream &os, NotPrintable const&) +{ + os << "???"; + return os; +} + +inline std::ostream &operator<<(std::ostream &os, DontCare const&) +{ + os << "_"; + return os; +} + +template +inline std::ostream &operator<<(std::ostream &os, ByRef &ref) { + os << "byRef(" << (T)ref << ")"; + return os; +} + +template +struct printArg +{ + static inline void print(std::ostream &os, T arg, bool withComma) + { + if (withComma) + os << ","; + os << arg; + } +}; + +template <> +struct printArg +{ + static void print(std::ostream &, NullType , bool) + { + } +}; + +class base_tuple +{ +protected: + base_tuple() + { + } +public: + virtual ~base_tuple() + { + } + virtual void printTo(std::ostream &os) const = 0; +}; + +template +struct no_cref { typedef X type; }; + +template +struct no_cref { typedef X type; }; + +template struct with_const { typedef const A type; }; +template struct with_const { typedef const A &type; }; +template struct with_const { typedef const A type; }; +template struct with_const { typedef const A &type; }; + +template struct base_type { typedef T type; }; +template struct base_type { typedef T type; }; +template struct base_type { typedef T type; }; +template struct base_type { typedef T type; }; + +template +struct comparer +{ + static inline bool compare(typename with_const::type a, typename with_const::type b) + { + return a == b; + } + static inline bool compare(DontCare, typename with_const::type) + { + return true; + } + template + static inline bool compare(const ByRef &a, typename with_const::type b) + { + return &a.arg == &b; + } +}; + +template +struct IsOutParamType { enum { value = false }; }; +template +struct IsOutParamType > { enum { value = true }; }; + +template +struct IsInParamType { enum { value = false }; }; +template +struct IsInParamType > { enum { value = true }; }; +template +struct IsInParamType > { enum { value = true }; }; + +template +struct do_assign; + +template +struct do_assign +{ + static void assign_to(T1 outparam, T2 *refparam) + { + *refparam = outparam.value; + } + static void assign_from(T1 inparam, T2 *refparam) + { + inparam.value = refparam; + } +}; + +template +struct do_assign +{ + static void assign_to(T1 outparam, T2 &refparam) + { + refparam = outparam.value; + } + static void assign_from(T1 inparam, T2 &refparam) + { + inparam.value = refparam; + } +}; + +template +struct do_assign +{ + static void assign_to(T1, T2) {} + static void assign_from(T1, T2) {} +}; + +template +void out_assign(T1 a, T2 b) +{ + do_assign::type>::value >::assign_to(a, b); +} + +template +void in_assign(T1 a, T2 b) +{ + do_assign::type>::value >::assign_from(a, b); +} + +template +class ref_tuple : public base_tuple +{ +public: + A a; + B b; + C c; + D d; + E e; + F f; + G g; + H h; + I i; + J j; + K k; + L l; + M m; + N n; + O o; + P p; + ref_tuple(A valueA = A(), B valueB = B(), C valueC = C(), D valueD = D(), E valueE = E(), F valueF = F(), G valueG = G(), H valueH = H(), I valueI = I(), J valueJ = J(), K valueK = K(), L valueL = L(), M valueM = M(), N valueN = N(), O valueO = O(), P valueP = P()) + : a(valueA), b(valueB), c(valueC), d(valueD), e(valueE), f(valueF), g(valueG), h(valueH), i(valueI), j(valueJ), k(valueK), l(valueL), m(valueM), n(valueN), o(valueO), p(valueP) + {} + virtual void printTo(std::ostream &os) const + { + os << "("; + printArg::print(os, a, false); + printArg::print(os, b, true); + printArg::print(os, c, true); + printArg::print(os, d, true); + printArg::print(os, e, true); + printArg::print(os, f, true); + printArg::print(os, g, true); + printArg::print(os, h, true); + printArg::print(os, i, true); + printArg::print(os, j, true); + printArg::print(os, k, true); + printArg::print(os, l, true); + printArg::print(os, m, true); + printArg::print(os, n, true); + printArg::print(os, o, true); + printArg

::compare(p, to.p)); + } + void assign_from(ref_tuple &from) + { + in_assign< typename store_as::type, A>(a, from.a); + in_assign< typename store_as::type, B>(b, from.b); + in_assign< typename store_as::type, C>(c, from.c); + in_assign< typename store_as::type, D>(d, from.d); + in_assign< typename store_as::type, E>(e, from.e); + in_assign< typename store_as::type, F>(f, from.f); + in_assign< typename store_as::type, G>(g, from.g); + in_assign< typename store_as::type, H>(h, from.h); + in_assign< typename store_as::type, I>(i, from.i); + in_assign< typename store_as::type, J>(j, from.j); + in_assign< typename store_as::type, K>(k, from.k); + in_assign< typename store_as::type, L>(l, from.l); + in_assign< typename store_as::type, M>(m, from.m); + in_assign< typename store_as::type, N>(n, from.n); + in_assign< typename store_as::type, O>(o, from.o); + in_assign< typename store_as::type, P>(p, from.p); + } + void assign_to(ref_tuple &to) + { + out_assign< typename store_as::type, A>(a, to.a); + out_assign< typename store_as::type, B>(b, to.b); + out_assign< typename store_as::type, C>(c, to.c); + out_assign< typename store_as::type, D>(d, to.d); + out_assign< typename store_as::type, E>(e, to.e); + out_assign< typename store_as::type, F>(f, to.f); + out_assign< typename store_as::type, G>(g, to.g); + out_assign< typename store_as::type, H>(h, to.h); + out_assign< typename store_as::type, I>(i, to.i); + out_assign< typename store_as::type, J>(j, to.j); + out_assign< typename store_as::type, K>(k, to.k); + out_assign< typename store_as::type, L>(l, to.l); + out_assign< typename store_as::type, M>(m, to.m); + out_assign< typename store_as::type, N>(n, to.n); + out_assign< typename store_as::type, O>(o, to.o); + out_assign< typename store_as::type, P>(p, to.p); + } + virtual void printTo(std::ostream &os) const + { + os << "("; + printArg::type>::print(os, a, false); + printArg::type>::print(os, b, true); + printArg::type>::print(os, c, true); + printArg::type>::print(os, d, true); + printArg::type>::print(os, e, true); + printArg::type>::print(os, f, true); + printArg::type>::print(os, g, true); + printArg::type>::print(os, h, true); + printArg::type>::print(os, i, true); + printArg::type>::print(os, j, true); + printArg::type>::print(os, k, true); + printArg::type>::print(os, l, true); + printArg::type>::print(os, m, true); + printArg::type>::print(os, n, true); + printArg::type>::print(os, o, true); + printArg::type>::print(os, p, true); + os << ")"; + } +}; + +inline std::ostream &operator<<(std::ostream &os, const MockRepository &repo); + +class BaseException +#ifndef HM_NO_EXCEPTIONS + : public BASE_EXCEPTION +#endif +{ +public: + ~BaseException() throw() {} + const char *what() const throw() { return txt.c_str(); } +protected: + std::string txt; +}; + +// exception types +class ExpectationException : public BaseException { +public: + ExpectationException(MockRepository *repo, const base_tuple *tuple, const char *funcName) + { + std::stringstream text; + text << "Function "; + text << funcName; + if (tuple) + tuple->printTo(text); + else + text << "(...)"; + text << " called with mismatching expectation!" << std::endl; + text << *repo; + txt = text.str(); + } +}; + +#ifdef LINUX_TARGET +#include +#endif + +class NotImplementedException : public BaseException { +public: + NotImplementedException(MockRepository *repo) + { + std::stringstream text; + text << "Function called without expectation!" << std::endl; + text << *repo; + +#ifdef LINUX_TARGET + void* stacktrace[256]; + size_t size = backtrace( stacktrace, sizeof(stacktrace) ); + if( size > 0 ) + { + text << "Stackdump:" << std::endl; + char **symbols = backtrace_symbols( stacktrace, size ); + for( size_t i = 0; i < size; i = i + 1 ) + { + text << symbols[i] << std::endl; + } + free( symbols ); + } +#endif + + txt = text.str(); + } +}; + +class CallMissingException : public BaseException { +public: + CallMissingException(MockRepository *repo) + { + std::stringstream text; + text << "Function with expectation not called!" << std::endl; + text << *repo; + txt = text.str(); + } +}; + +class ZombieMockException : public BaseException { +public: + ZombieMockException(MockRepository *repo) + { + std::stringstream text; + text << "Function called on mock that has already been destroyed!" << std::endl; + text << *repo; + +#ifdef LINUX_TARGET + void* stacktrace[256]; + size_t size = backtrace( stacktrace, sizeof(stacktrace) ); + if( size > 0 ) + { + text << "Stackdump:" << std::endl; + char **symbols = backtrace_symbols( stacktrace, size ); + for( size_t i = 0; i < size; i = i + 1 ) + { + text << symbols[i] << std::endl; + } + free( symbols ); + } +#endif + + txt = text.str(); + } +}; + +class NoResultSetUpException : public BaseException { +public: + NoResultSetUpException(MockRepository *repo, const base_tuple *tuple, const char *funcName) + { + std::stringstream text; + text << "No result set up on call to "; + text << funcName; + if (tuple) + tuple->printTo(text); + else + text << "(...)"; + text << std::endl; + text << *repo; + +#ifdef LINUX_TARGET + void* stacktrace[256]; + size_t size = backtrace( stacktrace, sizeof(stacktrace) ); + if( size > 0 ) + { + text << "Stackdump:" << std::endl; + char **symbols = backtrace_symbols( stacktrace, size ); + for( size_t i = 0; i < size; i = i + 1 ) + { + text << symbols[i] << std::endl; + } + free( symbols ); + } +#endif + + txt = text.str(); + } +}; + +// function-index-of-type +class func_index { +public: + int lci; + virtual int f0(int) { return lci=0; } virtual int f1(int) { return lci=1; } virtual int f2(int) { return lci=2; } virtual int f3(int) { return lci=3; } + virtual int f4(int) { return lci=4; } virtual int f5(int) { return lci=5; } virtual int f6(int) { return lci=6; } virtual int f7(int) { return lci=7; } + virtual int f8(int) { return lci=8; } virtual int f9(int) { return lci=9; } virtual int f10(int) { return lci=10; } virtual int f11(int) { return lci=11; } + virtual int f12(int) { return lci=12; } virtual int f13(int) { return lci=13; } virtual int f14(int) { return lci=14; } virtual int f15(int) { return lci=15; } + virtual int f16(int) { return lci=16; } virtual int f17(int) { return lci=17; } virtual int f18(int) { return lci=18; } virtual int f19(int) { return lci=19; } + virtual int f20(int) { return lci=20; } virtual int f21(int) { return lci=21; } virtual int f22(int) { return lci=22; } virtual int f23(int) { return lci=23; } + virtual int f24(int) { return lci=24; } virtual int f25(int) { return lci=25; } virtual int f26(int) { return lci=26; } virtual int f27(int) { return lci=27; } + virtual int f28(int) { return lci=28; } virtual int f29(int) { return lci=29; } virtual int f30(int) { return lci=30; } virtual int f31(int) { return lci=31; } + virtual int f32(int) { return lci=32; } virtual int f33(int) { return lci=33; } virtual int f34(int) { return lci=34; } virtual int f35(int) { return lci=35; } + virtual int f36(int) { return lci=36; } virtual int f37(int) { return lci=37; } virtual int f38(int) { return lci=38; } virtual int f39(int) { return lci=39; } + virtual int f40(int) { return lci=40; } virtual int f41(int) { return lci=41; } virtual int f42(int) { return lci=42; } virtual int f43(int) { return lci=43; } + virtual int f44(int) { return lci=44; } virtual int f45(int) { return lci=45; } virtual int f46(int) { return lci=46; } virtual int f47(int) { return lci=47; } + virtual int f48(int) { return lci=48; } virtual int f49(int) { return lci=49; } virtual int f50(int) { return lci=50; } virtual int f51(int) { return lci=51; } + virtual int f52(int) { return lci=52; } virtual int f53(int) { return lci=53; } virtual int f54(int) { return lci=54; } virtual int f55(int) { return lci=55; } + virtual int f56(int) { return lci=56; } virtual int f57(int) { return lci=57; } virtual int f58(int) { return lci=58; } virtual int f59(int) { return lci=59; } + virtual int f60(int) { return lci=60; } virtual int f61(int) { return lci=61; } virtual int f62(int) { return lci=62; } virtual int f63(int) { return lci=63; } + virtual int f64(int) { return lci=64; } virtual int f65(int) { return lci=65; } virtual int f66(int) { return lci=66; } virtual int f67(int) { return lci=67; } + virtual int f68(int) { return lci=68; } virtual int f69(int) { return lci=69; } virtual int f70(int) { return lci=70; } virtual int f71(int) { return lci=71; } + virtual int f72(int) { return lci=72; } virtual int f73(int) { return lci=73; } virtual int f74(int) { return lci=74; } virtual int f75(int) { return lci=75; } + virtual int f76(int) { return lci=76; } virtual int f77(int) { return lci=77; } virtual int f78(int) { return lci=78; } virtual int f79(int) { return lci=79; } + virtual int f80(int) { return lci=80; } virtual int f81(int) { return lci=81; } virtual int f82(int) { return lci=82; } virtual int f83(int) { return lci=83; } + virtual int f84(int) { return lci=84; } virtual int f85(int) { return lci=85; } virtual int f86(int) { return lci=86; } virtual int f87(int) { return lci=87; } + virtual int f88(int) { return lci=88; } virtual int f89(int) { return lci=89; } virtual int f90(int) { return lci=90; } virtual int f91(int) { return lci=91; } + virtual int f92(int) { return lci=92; } virtual int f93(int) { return lci=93; } virtual int f94(int) { return lci=94; } virtual int f95(int) { return lci=95; } + virtual int f96(int) { return lci=96; } virtual int f97(int) { return lci=97; } virtual int f98(int) { return lci=98; } virtual int f99(int) { return lci=99; } + virtual int f100(int) { return lci=100; } virtual int f101(int) { return lci=101; } virtual int f102(int) { return lci=102; } virtual int f103(int) { return lci=103; } + virtual int f104(int) { return lci=104; } virtual int f105(int) { return lci=105; } virtual int f106(int) { return lci=106; } virtual int f107(int) { return lci=107; } + virtual int f108(int) { return lci=108; } virtual int f109(int) { return lci=109; } virtual int f110(int) { return lci=110; } virtual int f111(int) { return lci=111; } + virtual int f112(int) { return lci=112; } virtual int f113(int) { return lci=113; } virtual int f114(int) { return lci=114; } virtual int f115(int) { return lci=115; } + virtual int f116(int) { return lci=116; } virtual int f117(int) { return lci=117; } virtual int f118(int) { return lci=118; } virtual int f119(int) { return lci=119; } + virtual int f120(int) { return lci=120; } virtual int f121(int) { return lci=121; } virtual int f122(int) { return lci=122; } virtual int f123(int) { return lci=123; } + virtual int f124(int) { return lci=124; } virtual int f125(int) { return lci=125; } virtual int f126(int) { return lci=126; } virtual int f127(int) { return lci=127; } + virtual int f128(int) { return lci=128; } virtual int f129(int) { return lci=129; } virtual int f130(int) { return lci=130; } virtual int f131(int) { return lci=131; } + virtual int f132(int) { return lci=132; } virtual int f133(int) { return lci=133; } virtual int f134(int) { return lci=134; } virtual int f135(int) { return lci=135; } + virtual int f136(int) { return lci=136; } virtual int f137(int) { return lci=137; } virtual int f138(int) { return lci=138; } virtual int f139(int) { return lci=139; } + virtual int f140(int) { return lci=140; } virtual int f141(int) { return lci=141; } virtual int f142(int) { return lci=142; } virtual int f143(int) { return lci=143; } + virtual int f144(int) { return lci=144; } virtual int f145(int) { return lci=145; } virtual int f146(int) { return lci=146; } virtual int f147(int) { return lci=147; } + virtual int f148(int) { return lci=148; } virtual int f149(int) { return lci=149; } virtual int f150(int) { return lci=150; } virtual int f151(int) { return lci=151; } + virtual int f152(int) { return lci=152; } virtual int f153(int) { return lci=153; } virtual int f154(int) { return lci=154; } virtual int f155(int) { return lci=155; } + virtual int f156(int) { return lci=156; } virtual int f157(int) { return lci=157; } virtual int f158(int) { return lci=158; } virtual int f159(int) { return lci=159; } + virtual int f160(int) { return lci=160; } virtual int f161(int) { return lci=161; } virtual int f162(int) { return lci=162; } virtual int f163(int) { return lci=163; } + virtual int f164(int) { return lci=164; } virtual int f165(int) { return lci=165; } virtual int f166(int) { return lci=166; } virtual int f167(int) { return lci=167; } + virtual int f168(int) { return lci=168; } virtual int f169(int) { return lci=169; } virtual int f170(int) { return lci=170; } virtual int f171(int) { return lci=171; } + virtual int f172(int) { return lci=172; } virtual int f173(int) { return lci=173; } virtual int f174(int) { return lci=174; } virtual int f175(int) { return lci=175; } + virtual int f176(int) { return lci=176; } virtual int f177(int) { return lci=177; } virtual int f178(int) { return lci=178; } virtual int f179(int) { return lci=179; } + virtual int f180(int) { return lci=180; } virtual int f181(int) { return lci=181; } virtual int f182(int) { return lci=182; } virtual int f183(int) { return lci=183; } + virtual int f184(int) { return lci=184; } virtual int f185(int) { return lci=185; } virtual int f186(int) { return lci=186; } virtual int f187(int) { return lci=187; } + virtual int f188(int) { return lci=188; } virtual int f189(int) { return lci=189; } virtual int f190(int) { return lci=190; } virtual int f191(int) { return lci=191; } + virtual int f192(int) { return lci=192; } virtual int f193(int) { return lci=193; } virtual int f194(int) { return lci=194; } virtual int f195(int) { return lci=195; } + virtual int f196(int) { return lci=196; } virtual int f197(int) { return lci=197; } virtual int f198(int) { return lci=198; } virtual int f199(int) { return lci=199; } + virtual int f200(int) { return lci=200; } virtual int f201(int) { return lci=201; } virtual int f202(int) { return lci=202; } virtual int f203(int) { return lci=203; } + virtual int f204(int) { return lci=204; } virtual int f205(int) { return lci=205; } virtual int f206(int) { return lci=206; } virtual int f207(int) { return lci=207; } + virtual int f208(int) { return lci=208; } virtual int f209(int) { return lci=209; } virtual int f210(int) { return lci=210; } virtual int f211(int) { return lci=211; } + virtual int f212(int) { return lci=212; } virtual int f213(int) { return lci=213; } virtual int f214(int) { return lci=214; } virtual int f215(int) { return lci=215; } + virtual int f216(int) { return lci=216; } virtual int f217(int) { return lci=217; } virtual int f218(int) { return lci=218; } virtual int f219(int) { return lci=219; } + virtual int f220(int) { return lci=220; } virtual int f221(int) { return lci=221; } virtual int f222(int) { return lci=222; } virtual int f223(int) { return lci=223; } + virtual int f224(int) { return lci=224; } virtual int f225(int) { return lci=225; } virtual int f226(int) { return lci=226; } virtual int f227(int) { return lci=227; } + virtual int f228(int) { return lci=228; } virtual int f229(int) { return lci=229; } virtual int f230(int) { return lci=230; } virtual int f231(int) { return lci=231; } + virtual int f232(int) { return lci=232; } virtual int f233(int) { return lci=233; } virtual int f234(int) { return lci=234; } virtual int f235(int) { return lci=235; } + virtual int f236(int) { return lci=236; } virtual int f237(int) { return lci=237; } virtual int f238(int) { return lci=238; } virtual int f239(int) { return lci=239; } + virtual int f240(int) { return lci=240; } virtual int f241(int) { return lci=241; } virtual int f242(int) { return lci=242; } virtual int f243(int) { return lci=243; } + virtual int f244(int) { return lci=244; } virtual int f245(int) { return lci=245; } virtual int f246(int) { return lci=246; } virtual int f247(int) { return lci=247; } + virtual int f248(int) { return lci=248; } virtual int f249(int) { return lci=249; } virtual int f250(int) { return lci=250; } virtual int f251(int) { return lci=251; } + virtual int f252(int) { return lci=252; } virtual int f253(int) { return lci=253; } virtual int f254(int) { return lci=254; } virtual int f255(int) { return lci=255; } + virtual int f256(int) { return lci=256; } virtual int f257(int) { return lci=257; } virtual int f258(int) { return lci=258; } virtual int f259(int) { return lci=259; } + virtual int f260(int) { return lci=260; } virtual int f261(int) { return lci=261; } virtual int f262(int) { return lci=262; } virtual int f263(int) { return lci=263; } + virtual int f264(int) { return lci=264; } virtual int f265(int) { return lci=265; } virtual int f266(int) { return lci=266; } virtual int f267(int) { return lci=267; } + virtual int f268(int) { return lci=268; } virtual int f269(int) { return lci=269; } virtual int f270(int) { return lci=270; } virtual int f271(int) { return lci=271; } + virtual int f272(int) { return lci=272; } virtual int f273(int) { return lci=273; } virtual int f274(int) { return lci=274; } virtual int f275(int) { return lci=275; } + virtual int f276(int) { return lci=276; } virtual int f277(int) { return lci=277; } virtual int f278(int) { return lci=278; } virtual int f279(int) { return lci=279; } + virtual int f280(int) { return lci=280; } virtual int f281(int) { return lci=281; } virtual int f282(int) { return lci=282; } virtual int f283(int) { return lci=283; } + virtual int f284(int) { return lci=284; } virtual int f285(int) { return lci=285; } virtual int f286(int) { return lci=286; } virtual int f287(int) { return lci=287; } + virtual int f288(int) { return lci=288; } virtual int f289(int) { return lci=289; } virtual int f290(int) { return lci=290; } virtual int f291(int) { return lci=291; } + virtual int f292(int) { return lci=292; } virtual int f293(int) { return lci=293; } virtual int f294(int) { return lci=294; } virtual int f295(int) { return lci=295; } + virtual int f296(int) { return lci=296; } virtual int f297(int) { return lci=297; } virtual int f298(int) { return lci=298; } virtual int f299(int) { return lci=299; } + virtual int f300(int) { return lci=300; } virtual int f301(int) { return lci=301; } virtual int f302(int) { return lci=302; } virtual int f303(int) { return lci=303; } + virtual int f304(int) { return lci=304; } virtual int f305(int) { return lci=305; } virtual int f306(int) { return lci=306; } virtual int f307(int) { return lci=307; } + virtual int f308(int) { return lci=308; } virtual int f309(int) { return lci=309; } virtual int f310(int) { return lci=310; } virtual int f311(int) { return lci=311; } + virtual int f312(int) { return lci=312; } virtual int f313(int) { return lci=313; } virtual int f314(int) { return lci=314; } virtual int f315(int) { return lci=315; } + virtual int f316(int) { return lci=316; } virtual int f317(int) { return lci=317; } virtual int f318(int) { return lci=318; } virtual int f319(int) { return lci=319; } + virtual int f320(int) { return lci=320; } virtual int f321(int) { return lci=321; } virtual int f322(int) { return lci=322; } virtual int f323(int) { return lci=323; } + virtual int f324(int) { return lci=324; } virtual int f325(int) { return lci=325; } virtual int f326(int) { return lci=326; } virtual int f327(int) { return lci=327; } + virtual int f328(int) { return lci=328; } virtual int f329(int) { return lci=329; } virtual int f330(int) { return lci=330; } virtual int f331(int) { return lci=331; } + virtual int f332(int) { return lci=332; } virtual int f333(int) { return lci=333; } virtual int f334(int) { return lci=334; } virtual int f335(int) { return lci=335; } + virtual int f336(int) { return lci=336; } virtual int f337(int) { return lci=337; } virtual int f338(int) { return lci=338; } virtual int f339(int) { return lci=339; } + virtual int f340(int) { return lci=340; } virtual int f341(int) { return lci=341; } virtual int f342(int) { return lci=342; } virtual int f343(int) { return lci=343; } + virtual int f344(int) { return lci=344; } virtual int f345(int) { return lci=345; } virtual int f346(int) { return lci=346; } virtual int f347(int) { return lci=347; } + virtual int f348(int) { return lci=348; } virtual int f349(int) { return lci=349; } virtual int f350(int) { return lci=350; } virtual int f351(int) { return lci=351; } + virtual int f352(int) { return lci=352; } virtual int f353(int) { return lci=353; } virtual int f354(int) { return lci=354; } virtual int f355(int) { return lci=355; } + virtual int f356(int) { return lci=356; } virtual int f357(int) { return lci=357; } virtual int f358(int) { return lci=358; } virtual int f359(int) { return lci=359; } + virtual int f360(int) { return lci=360; } virtual int f361(int) { return lci=361; } virtual int f362(int) { return lci=362; } virtual int f363(int) { return lci=363; } + virtual int f364(int) { return lci=364; } virtual int f365(int) { return lci=365; } virtual int f366(int) { return lci=366; } virtual int f367(int) { return lci=367; } + virtual int f368(int) { return lci=368; } virtual int f369(int) { return lci=369; } virtual int f370(int) { return lci=370; } virtual int f371(int) { return lci=371; } + virtual int f372(int) { return lci=372; } virtual int f373(int) { return lci=373; } virtual int f374(int) { return lci=374; } virtual int f375(int) { return lci=375; } + virtual int f376(int) { return lci=376; } virtual int f377(int) { return lci=377; } virtual int f378(int) { return lci=378; } virtual int f379(int) { return lci=379; } + virtual int f380(int) { return lci=380; } virtual int f381(int) { return lci=381; } virtual int f382(int) { return lci=382; } virtual int f383(int) { return lci=383; } + virtual int f384(int) { return lci=384; } virtual int f385(int) { return lci=385; } virtual int f386(int) { return lci=386; } virtual int f387(int) { return lci=387; } + virtual int f388(int) { return lci=388; } virtual int f389(int) { return lci=389; } virtual int f390(int) { return lci=390; } virtual int f391(int) { return lci=391; } + virtual int f392(int) { return lci=392; } virtual int f393(int) { return lci=393; } virtual int f394(int) { return lci=394; } virtual int f395(int) { return lci=395; } + virtual int f396(int) { return lci=396; } virtual int f397(int) { return lci=397; } virtual int f398(int) { return lci=398; } virtual int f399(int) { return lci=399; } + virtual int f400(int) { return lci=400; } virtual int f401(int) { return lci=401; } virtual int f402(int) { return lci=402; } virtual int f403(int) { return lci=403; } + virtual int f404(int) { return lci=404; } virtual int f405(int) { return lci=405; } virtual int f406(int) { return lci=406; } virtual int f407(int) { return lci=407; } + virtual int f408(int) { return lci=408; } virtual int f409(int) { return lci=409; } virtual int f410(int) { return lci=410; } virtual int f411(int) { return lci=411; } + virtual int f412(int) { return lci=412; } virtual int f413(int) { return lci=413; } virtual int f414(int) { return lci=414; } virtual int f415(int) { return lci=415; } + virtual int f416(int) { return lci=416; } virtual int f417(int) { return lci=417; } virtual int f418(int) { return lci=418; } virtual int f419(int) { return lci=419; } + virtual int f420(int) { return lci=420; } virtual int f421(int) { return lci=421; } virtual int f422(int) { return lci=422; } virtual int f423(int) { return lci=423; } + virtual int f424(int) { return lci=424; } virtual int f425(int) { return lci=425; } virtual int f426(int) { return lci=426; } virtual int f427(int) { return lci=427; } + virtual int f428(int) { return lci=428; } virtual int f429(int) { return lci=429; } virtual int f430(int) { return lci=430; } virtual int f431(int) { return lci=431; } + virtual int f432(int) { return lci=432; } virtual int f433(int) { return lci=433; } virtual int f434(int) { return lci=434; } virtual int f435(int) { return lci=435; } + virtual int f436(int) { return lci=436; } virtual int f437(int) { return lci=437; } virtual int f438(int) { return lci=438; } virtual int f439(int) { return lci=439; } + virtual int f440(int) { return lci=440; } virtual int f441(int) { return lci=441; } virtual int f442(int) { return lci=442; } virtual int f443(int) { return lci=443; } + virtual int f444(int) { return lci=444; } virtual int f445(int) { return lci=445; } virtual int f446(int) { return lci=446; } virtual int f447(int) { return lci=447; } + virtual int f448(int) { return lci=448; } virtual int f449(int) { return lci=449; } virtual int f450(int) { return lci=450; } virtual int f451(int) { return lci=451; } + virtual int f452(int) { return lci=452; } virtual int f453(int) { return lci=453; } virtual int f454(int) { return lci=454; } virtual int f455(int) { return lci=455; } + virtual int f456(int) { return lci=456; } virtual int f457(int) { return lci=457; } virtual int f458(int) { return lci=458; } virtual int f459(int) { return lci=459; } + virtual int f460(int) { return lci=460; } virtual int f461(int) { return lci=461; } virtual int f462(int) { return lci=462; } virtual int f463(int) { return lci=463; } + virtual int f464(int) { return lci=464; } virtual int f465(int) { return lci=465; } virtual int f466(int) { return lci=466; } virtual int f467(int) { return lci=467; } + virtual int f468(int) { return lci=468; } virtual int f469(int) { return lci=469; } virtual int f470(int) { return lci=470; } virtual int f471(int) { return lci=471; } + virtual int f472(int) { return lci=472; } virtual int f473(int) { return lci=473; } virtual int f474(int) { return lci=474; } virtual int f475(int) { return lci=475; } + virtual int f476(int) { return lci=476; } virtual int f477(int) { return lci=477; } virtual int f478(int) { return lci=478; } virtual int f479(int) { return lci=479; } + virtual int f480(int) { return lci=480; } virtual int f481(int) { return lci=481; } virtual int f482(int) { return lci=482; } virtual int f483(int) { return lci=483; } + virtual int f484(int) { return lci=484; } virtual int f485(int) { return lci=485; } virtual int f486(int) { return lci=486; } virtual int f487(int) { return lci=487; } + virtual int f488(int) { return lci=488; } virtual int f489(int) { return lci=489; } virtual int f490(int) { return lci=490; } virtual int f491(int) { return lci=491; } + virtual int f492(int) { return lci=492; } virtual int f493(int) { return lci=493; } virtual int f494(int) { return lci=494; } virtual int f495(int) { return lci=495; } + virtual int f496(int) { return lci=496; } virtual int f497(int) { return lci=497; } virtual int f498(int) { return lci=498; } virtual int f499(int) { return lci=499; } + virtual int f500(int) { return lci=500; } virtual int f501(int) { return lci=501; } virtual int f502(int) { return lci=502; } virtual int f503(int) { return lci=503; } + virtual int f504(int) { return lci=504; } virtual int f505(int) { return lci=505; } virtual int f506(int) { return lci=506; } virtual int f507(int) { return lci=507; } + virtual int f508(int) { return lci=508; } virtual int f509(int) { return lci=509; } virtual int f510(int) { return lci=510; } virtual int f511(int) { return lci=511; } + virtual int f512(int) { return lci=512; } virtual int f513(int) { return lci=513; } virtual int f514(int) { return lci=514; } virtual int f515(int) { return lci=515; } + virtual int f516(int) { return lci=516; } virtual int f517(int) { return lci=517; } virtual int f518(int) { return lci=518; } virtual int f519(int) { return lci=519; } + virtual int f520(int) { return lci=520; } virtual int f521(int) { return lci=521; } virtual int f522(int) { return lci=522; } virtual int f523(int) { return lci=523; } + virtual int f524(int) { return lci=524; } virtual int f525(int) { return lci=525; } virtual int f526(int) { return lci=526; } virtual int f527(int) { return lci=527; } + virtual int f528(int) { return lci=528; } virtual int f529(int) { return lci=529; } virtual int f530(int) { return lci=530; } virtual int f531(int) { return lci=531; } + virtual int f532(int) { return lci=532; } virtual int f533(int) { return lci=533; } virtual int f534(int) { return lci=534; } virtual int f535(int) { return lci=535; } + virtual int f536(int) { return lci=536; } virtual int f537(int) { return lci=537; } virtual int f538(int) { return lci=538; } virtual int f539(int) { return lci=539; } + virtual int f540(int) { return lci=540; } virtual int f541(int) { return lci=541; } virtual int f542(int) { return lci=542; } virtual int f543(int) { return lci=543; } + virtual int f544(int) { return lci=544; } virtual int f545(int) { return lci=545; } virtual int f546(int) { return lci=546; } virtual int f547(int) { return lci=547; } + virtual int f548(int) { return lci=548; } virtual int f549(int) { return lci=549; } virtual int f550(int) { return lci=550; } virtual int f551(int) { return lci=551; } + virtual int f552(int) { return lci=552; } virtual int f553(int) { return lci=553; } virtual int f554(int) { return lci=554; } virtual int f555(int) { return lci=555; } + virtual int f556(int) { return lci=556; } virtual int f557(int) { return lci=557; } virtual int f558(int) { return lci=558; } virtual int f559(int) { return lci=559; } + virtual int f560(int) { return lci=560; } virtual int f561(int) { return lci=561; } virtual int f562(int) { return lci=562; } virtual int f563(int) { return lci=563; } + virtual int f564(int) { return lci=564; } virtual int f565(int) { return lci=565; } virtual int f566(int) { return lci=566; } virtual int f567(int) { return lci=567; } + virtual int f568(int) { return lci=568; } virtual int f569(int) { return lci=569; } virtual int f570(int) { return lci=570; } virtual int f571(int) { return lci=571; } + virtual int f572(int) { return lci=572; } virtual int f573(int) { return lci=573; } virtual int f574(int) { return lci=574; } virtual int f575(int) { return lci=575; } + virtual int f576(int) { return lci=576; } virtual int f577(int) { return lci=577; } virtual int f578(int) { return lci=578; } virtual int f579(int) { return lci=579; } + virtual int f580(int) { return lci=580; } virtual int f581(int) { return lci=581; } virtual int f582(int) { return lci=582; } virtual int f583(int) { return lci=583; } + virtual int f584(int) { return lci=584; } virtual int f585(int) { return lci=585; } virtual int f586(int) { return lci=586; } virtual int f587(int) { return lci=587; } + virtual int f588(int) { return lci=588; } virtual int f589(int) { return lci=589; } virtual int f590(int) { return lci=590; } virtual int f591(int) { return lci=591; } + virtual int f592(int) { return lci=592; } virtual int f593(int) { return lci=593; } virtual int f594(int) { return lci=594; } virtual int f595(int) { return lci=595; } + virtual int f596(int) { return lci=596; } virtual int f597(int) { return lci=597; } virtual int f598(int) { return lci=598; } virtual int f599(int) { return lci=599; } + virtual int f600(int) { return lci=600; } virtual int f601(int) { return lci=601; } virtual int f602(int) { return lci=602; } virtual int f603(int) { return lci=603; } + virtual int f604(int) { return lci=604; } virtual int f605(int) { return lci=605; } virtual int f606(int) { return lci=606; } virtual int f607(int) { return lci=607; } + virtual int f608(int) { return lci=608; } virtual int f609(int) { return lci=609; } virtual int f610(int) { return lci=610; } virtual int f611(int) { return lci=611; } + virtual int f612(int) { return lci=612; } virtual int f613(int) { return lci=613; } virtual int f614(int) { return lci=614; } virtual int f615(int) { return lci=615; } + virtual int f616(int) { return lci=616; } virtual int f617(int) { return lci=617; } virtual int f618(int) { return lci=618; } virtual int f619(int) { return lci=619; } + virtual int f620(int) { return lci=620; } virtual int f621(int) { return lci=621; } virtual int f622(int) { return lci=622; } virtual int f623(int) { return lci=623; } + virtual int f624(int) { return lci=624; } virtual int f625(int) { return lci=625; } virtual int f626(int) { return lci=626; } virtual int f627(int) { return lci=627; } + virtual int f628(int) { return lci=628; } virtual int f629(int) { return lci=629; } virtual int f630(int) { return lci=630; } virtual int f631(int) { return lci=631; } + virtual int f632(int) { return lci=632; } virtual int f633(int) { return lci=633; } virtual int f634(int) { return lci=634; } virtual int f635(int) { return lci=635; } + virtual int f636(int) { return lci=636; } virtual int f637(int) { return lci=637; } virtual int f638(int) { return lci=638; } virtual int f639(int) { return lci=639; } + virtual int f640(int) { return lci=640; } virtual int f641(int) { return lci=641; } virtual int f642(int) { return lci=642; } virtual int f643(int) { return lci=643; } + virtual int f644(int) { return lci=644; } virtual int f645(int) { return lci=645; } virtual int f646(int) { return lci=646; } virtual int f647(int) { return lci=647; } + virtual int f648(int) { return lci=648; } virtual int f649(int) { return lci=649; } virtual int f650(int) { return lci=650; } virtual int f651(int) { return lci=651; } + virtual int f652(int) { return lci=652; } virtual int f653(int) { return lci=653; } virtual int f654(int) { return lci=654; } virtual int f655(int) { return lci=655; } + virtual int f656(int) { return lci=656; } virtual int f657(int) { return lci=657; } virtual int f658(int) { return lci=658; } virtual int f659(int) { return lci=659; } + virtual int f660(int) { return lci=660; } virtual int f661(int) { return lci=661; } virtual int f662(int) { return lci=662; } virtual int f663(int) { return lci=663; } + virtual int f664(int) { return lci=664; } virtual int f665(int) { return lci=665; } virtual int f666(int) { return lci=666; } virtual int f667(int) { return lci=667; } + virtual int f668(int) { return lci=668; } virtual int f669(int) { return lci=669; } virtual int f670(int) { return lci=670; } virtual int f671(int) { return lci=671; } + virtual int f672(int) { return lci=672; } virtual int f673(int) { return lci=673; } virtual int f674(int) { return lci=674; } virtual int f675(int) { return lci=675; } + virtual int f676(int) { return lci=676; } virtual int f677(int) { return lci=677; } virtual int f678(int) { return lci=678; } virtual int f679(int) { return lci=679; } + virtual int f680(int) { return lci=680; } virtual int f681(int) { return lci=681; } virtual int f682(int) { return lci=682; } virtual int f683(int) { return lci=683; } + virtual int f684(int) { return lci=684; } virtual int f685(int) { return lci=685; } virtual int f686(int) { return lci=686; } virtual int f687(int) { return lci=687; } + virtual int f688(int) { return lci=688; } virtual int f689(int) { return lci=689; } virtual int f690(int) { return lci=690; } virtual int f691(int) { return lci=691; } + virtual int f692(int) { return lci=692; } virtual int f693(int) { return lci=693; } virtual int f694(int) { return lci=694; } virtual int f695(int) { return lci=695; } + virtual int f696(int) { return lci=696; } virtual int f697(int) { return lci=697; } virtual int f698(int) { return lci=698; } virtual int f699(int) { return lci=699; } + virtual int f700(int) { return lci=700; } virtual int f701(int) { return lci=701; } virtual int f702(int) { return lci=702; } virtual int f703(int) { return lci=703; } + virtual int f704(int) { return lci=704; } virtual int f705(int) { return lci=705; } virtual int f706(int) { return lci=706; } virtual int f707(int) { return lci=707; } + virtual int f708(int) { return lci=708; } virtual int f709(int) { return lci=709; } virtual int f710(int) { return lci=710; } virtual int f711(int) { return lci=711; } + virtual int f712(int) { return lci=712; } virtual int f713(int) { return lci=713; } virtual int f714(int) { return lci=714; } virtual int f715(int) { return lci=715; } + virtual int f716(int) { return lci=716; } virtual int f717(int) { return lci=717; } virtual int f718(int) { return lci=718; } virtual int f719(int) { return lci=719; } + virtual int f720(int) { return lci=720; } virtual int f721(int) { return lci=721; } virtual int f722(int) { return lci=722; } virtual int f723(int) { return lci=723; } + virtual int f724(int) { return lci=724; } virtual int f725(int) { return lci=725; } virtual int f726(int) { return lci=726; } virtual int f727(int) { return lci=727; } + virtual int f728(int) { return lci=728; } virtual int f729(int) { return lci=729; } virtual int f730(int) { return lci=730; } virtual int f731(int) { return lci=731; } + virtual int f732(int) { return lci=732; } virtual int f733(int) { return lci=733; } virtual int f734(int) { return lci=734; } virtual int f735(int) { return lci=735; } + virtual int f736(int) { return lci=736; } virtual int f737(int) { return lci=737; } virtual int f738(int) { return lci=738; } virtual int f739(int) { return lci=739; } + virtual int f740(int) { return lci=740; } virtual int f741(int) { return lci=741; } virtual int f742(int) { return lci=742; } virtual int f743(int) { return lci=743; } + virtual int f744(int) { return lci=744; } virtual int f745(int) { return lci=745; } virtual int f746(int) { return lci=746; } virtual int f747(int) { return lci=747; } + virtual int f748(int) { return lci=748; } virtual int f749(int) { return lci=749; } virtual int f750(int) { return lci=750; } virtual int f751(int) { return lci=751; } + virtual int f752(int) { return lci=752; } virtual int f753(int) { return lci=753; } virtual int f754(int) { return lci=754; } virtual int f755(int) { return lci=755; } + virtual int f756(int) { return lci=756; } virtual int f757(int) { return lci=757; } virtual int f758(int) { return lci=758; } virtual int f759(int) { return lci=759; } + virtual int f760(int) { return lci=760; } virtual int f761(int) { return lci=761; } virtual int f762(int) { return lci=762; } virtual int f763(int) { return lci=763; } + virtual int f764(int) { return lci=764; } virtual int f765(int) { return lci=765; } virtual int f766(int) { return lci=766; } virtual int f767(int) { return lci=767; } + virtual int f768(int) { return lci=768; } virtual int f769(int) { return lci=769; } virtual int f770(int) { return lci=770; } virtual int f771(int) { return lci=771; } + virtual int f772(int) { return lci=772; } virtual int f773(int) { return lci=773; } virtual int f774(int) { return lci=774; } virtual int f775(int) { return lci=775; } + virtual int f776(int) { return lci=776; } virtual int f777(int) { return lci=777; } virtual int f778(int) { return lci=778; } virtual int f779(int) { return lci=779; } + virtual int f780(int) { return lci=780; } virtual int f781(int) { return lci=781; } virtual int f782(int) { return lci=782; } virtual int f783(int) { return lci=783; } + virtual int f784(int) { return lci=784; } virtual int f785(int) { return lci=785; } virtual int f786(int) { return lci=786; } virtual int f787(int) { return lci=787; } + virtual int f788(int) { return lci=788; } virtual int f789(int) { return lci=789; } virtual int f790(int) { return lci=790; } virtual int f791(int) { return lci=791; } + virtual int f792(int) { return lci=792; } virtual int f793(int) { return lci=793; } virtual int f794(int) { return lci=794; } virtual int f795(int) { return lci=795; } + virtual int f796(int) { return lci=796; } virtual int f797(int) { return lci=797; } virtual int f798(int) { return lci=798; } virtual int f799(int) { return lci=799; } + virtual int f800(int) { return lci=800; } virtual int f801(int) { return lci=801; } virtual int f802(int) { return lci=802; } virtual int f803(int) { return lci=803; } + virtual int f804(int) { return lci=804; } virtual int f805(int) { return lci=805; } virtual int f806(int) { return lci=806; } virtual int f807(int) { return lci=807; } + virtual int f808(int) { return lci=808; } virtual int f809(int) { return lci=809; } virtual int f810(int) { return lci=810; } virtual int f811(int) { return lci=811; } + virtual int f812(int) { return lci=812; } virtual int f813(int) { return lci=813; } virtual int f814(int) { return lci=814; } virtual int f815(int) { return lci=815; } + virtual int f816(int) { return lci=816; } virtual int f817(int) { return lci=817; } virtual int f818(int) { return lci=818; } virtual int f819(int) { return lci=819; } + virtual int f820(int) { return lci=820; } virtual int f821(int) { return lci=821; } virtual int f822(int) { return lci=822; } virtual int f823(int) { return lci=823; } + virtual int f824(int) { return lci=824; } virtual int f825(int) { return lci=825; } virtual int f826(int) { return lci=826; } virtual int f827(int) { return lci=827; } + virtual int f828(int) { return lci=828; } virtual int f829(int) { return lci=829; } virtual int f830(int) { return lci=830; } virtual int f831(int) { return lci=831; } + virtual int f832(int) { return lci=832; } virtual int f833(int) { return lci=833; } virtual int f834(int) { return lci=834; } virtual int f835(int) { return lci=835; } + virtual int f836(int) { return lci=836; } virtual int f837(int) { return lci=837; } virtual int f838(int) { return lci=838; } virtual int f839(int) { return lci=839; } + virtual int f840(int) { return lci=840; } virtual int f841(int) { return lci=841; } virtual int f842(int) { return lci=842; } virtual int f843(int) { return lci=843; } + virtual int f844(int) { return lci=844; } virtual int f845(int) { return lci=845; } virtual int f846(int) { return lci=846; } virtual int f847(int) { return lci=847; } + virtual int f848(int) { return lci=848; } virtual int f849(int) { return lci=849; } virtual int f850(int) { return lci=850; } virtual int f851(int) { return lci=851; } + virtual int f852(int) { return lci=852; } virtual int f853(int) { return lci=853; } virtual int f854(int) { return lci=854; } virtual int f855(int) { return lci=855; } + virtual int f856(int) { return lci=856; } virtual int f857(int) { return lci=857; } virtual int f858(int) { return lci=858; } virtual int f859(int) { return lci=859; } + virtual int f860(int) { return lci=860; } virtual int f861(int) { return lci=861; } virtual int f862(int) { return lci=862; } virtual int f863(int) { return lci=863; } + virtual int f864(int) { return lci=864; } virtual int f865(int) { return lci=865; } virtual int f866(int) { return lci=866; } virtual int f867(int) { return lci=867; } + virtual int f868(int) { return lci=868; } virtual int f869(int) { return lci=869; } virtual int f870(int) { return lci=870; } virtual int f871(int) { return lci=871; } + virtual int f872(int) { return lci=872; } virtual int f873(int) { return lci=873; } virtual int f874(int) { return lci=874; } virtual int f875(int) { return lci=875; } + virtual int f876(int) { return lci=876; } virtual int f877(int) { return lci=877; } virtual int f878(int) { return lci=878; } virtual int f879(int) { return lci=879; } + virtual int f880(int) { return lci=880; } virtual int f881(int) { return lci=881; } virtual int f882(int) { return lci=882; } virtual int f883(int) { return lci=883; } + virtual int f884(int) { return lci=884; } virtual int f885(int) { return lci=885; } virtual int f886(int) { return lci=886; } virtual int f887(int) { return lci=887; } + virtual int f888(int) { return lci=888; } virtual int f889(int) { return lci=889; } virtual int f890(int) { return lci=890; } virtual int f891(int) { return lci=891; } + virtual int f892(int) { return lci=892; } virtual int f893(int) { return lci=893; } virtual int f894(int) { return lci=894; } virtual int f895(int) { return lci=895; } + virtual int f896(int) { return lci=896; } virtual int f897(int) { return lci=897; } virtual int f898(int) { return lci=898; } virtual int f899(int) { return lci=899; } + virtual int f900(int) { return lci=900; } virtual int f901(int) { return lci=901; } virtual int f902(int) { return lci=902; } virtual int f903(int) { return lci=903; } + virtual int f904(int) { return lci=904; } virtual int f905(int) { return lci=905; } virtual int f906(int) { return lci=906; } virtual int f907(int) { return lci=907; } + virtual int f908(int) { return lci=908; } virtual int f909(int) { return lci=909; } virtual int f910(int) { return lci=910; } virtual int f911(int) { return lci=911; } + virtual int f912(int) { return lci=912; } virtual int f913(int) { return lci=913; } virtual int f914(int) { return lci=914; } virtual int f915(int) { return lci=915; } + virtual int f916(int) { return lci=916; } virtual int f917(int) { return lci=917; } virtual int f918(int) { return lci=918; } virtual int f919(int) { return lci=919; } + virtual int f920(int) { return lci=920; } virtual int f921(int) { return lci=921; } virtual int f922(int) { return lci=922; } virtual int f923(int) { return lci=923; } + virtual int f924(int) { return lci=924; } virtual int f925(int) { return lci=925; } virtual int f926(int) { return lci=926; } virtual int f927(int) { return lci=927; } + virtual int f928(int) { return lci=928; } virtual int f929(int) { return lci=929; } virtual int f930(int) { return lci=930; } virtual int f931(int) { return lci=931; } + virtual int f932(int) { return lci=932; } virtual int f933(int) { return lci=933; } virtual int f934(int) { return lci=934; } virtual int f935(int) { return lci=935; } + virtual int f936(int) { return lci=936; } virtual int f937(int) { return lci=937; } virtual int f938(int) { return lci=938; } virtual int f939(int) { return lci=939; } + virtual int f940(int) { return lci=940; } virtual int f941(int) { return lci=941; } virtual int f942(int) { return lci=942; } virtual int f943(int) { return lci=943; } + virtual int f944(int) { return lci=944; } virtual int f945(int) { return lci=945; } virtual int f946(int) { return lci=946; } virtual int f947(int) { return lci=947; } + virtual int f948(int) { return lci=948; } virtual int f949(int) { return lci=949; } virtual int f950(int) { return lci=950; } virtual int f951(int) { return lci=951; } + virtual int f952(int) { return lci=952; } virtual int f953(int) { return lci=953; } virtual int f954(int) { return lci=954; } virtual int f955(int) { return lci=955; } + virtual int f956(int) { return lci=956; } virtual int f957(int) { return lci=957; } virtual int f958(int) { return lci=958; } virtual int f959(int) { return lci=959; } + virtual int f960(int) { return lci=960; } virtual int f961(int) { return lci=961; } virtual int f962(int) { return lci=962; } virtual int f963(int) { return lci=963; } + virtual int f964(int) { return lci=964; } virtual int f965(int) { return lci=965; } virtual int f966(int) { return lci=966; } virtual int f967(int) { return lci=967; } + virtual int f968(int) { return lci=968; } virtual int f969(int) { return lci=969; } virtual int f970(int) { return lci=970; } virtual int f971(int) { return lci=971; } + virtual int f972(int) { return lci=972; } virtual int f973(int) { return lci=973; } virtual int f974(int) { return lci=974; } virtual int f975(int) { return lci=975; } + virtual int f976(int) { return lci=976; } virtual int f977(int) { return lci=977; } virtual int f978(int) { return lci=978; } virtual int f979(int) { return lci=979; } + virtual int f980(int) { return lci=980; } virtual int f981(int) { return lci=981; } virtual int f982(int) { return lci=982; } virtual int f983(int) { return lci=983; } + virtual int f984(int) { return lci=984; } virtual int f985(int) { return lci=985; } virtual int f986(int) { return lci=986; } virtual int f987(int) { return lci=987; } + virtual int f988(int) { return lci=988; } virtual int f989(int) { return lci=989; } virtual int f990(int) { return lci=990; } virtual int f991(int) { return lci=991; } + virtual int f992(int) { return lci=992; } virtual int f993(int) { return lci=993; } virtual int f994(int) { return lci=994; } virtual int f995(int) { return lci=995; } + virtual int f996(int) { return lci=996; } virtual int f997(int) { return lci=997; } virtual int f998(int) { return lci=998; } virtual int f999(int) { return lci=999; } + virtual int f1000(int) { return lci=1000; } virtual int f1001(int) { return lci=1001; } virtual int f1002(int) { return lci=1002; } virtual int f1003(int) { return lci=1003; } + virtual int f1004(int) { return lci=1004; } virtual int f1005(int) { return lci=1005; } virtual int f1006(int) { return lci=1006; } virtual int f1007(int) { return lci=1007; } + virtual int f1008(int) { return lci=1008; } virtual int f1009(int) { return lci=1009; } virtual int f1010(int) { return lci=1010; } virtual int f1011(int) { return lci=1011; } + virtual int f1012(int) { return lci=1012; } virtual int f1013(int) { return lci=1013; } virtual int f1014(int) { return lci=1014; } virtual int f1015(int) { return lci=1015; } + virtual int f1016(int) { return lci=1016; } virtual int f1017(int) { return lci=1017; } virtual int f1018(int) { return lci=1018; } virtual int f1019(int) { return lci=1019; } + virtual int f1020(int) { return lci=1020; } virtual int f1021(int) { return lci=1021; } virtual int f1022(int) { return lci=1022; } virtual int f1023(int) { return lci=1023; } + virtual ~func_index() {} +}; + +#ifdef _MSC_VER +template +int virtual_function_index(unsigned char *func) +{ + if (*func == 0xE9) + { + return virtual_function_index<0>(func + 5 + *(unsigned int *)(func + 1)); + } + else + { +#ifdef _WIN64 + func++; // Add one to the pointer to skip the REX prefix used to access 64-bit registers. +#endif + switch (*(unsigned int *)func) + { // mov ecx, this; jump [eax + v/Ib/Iw] + case 0x20ff018b: return 0; +#ifdef _WIN32 + case 0x0424448b: + if (func[7] == 0x20) + return 0; + return *(unsigned char *)(func + 8) / sizeof(void*); +#endif + case 0x60ff018b: return *(unsigned char *)(func + sizeof(int)) / sizeof(void*); + case 0xA0ff018b: return *(unsigned long *)(func + sizeof(int)) / sizeof(void*); + default: return -1; + } + } +} + +#endif + +template +std::pair virtual_index(T t) +{ +#if defined(__GNUG__) + union { + T t; + struct + { + unsigned long value; + unsigned long baseoffs; + } u; + } conv; + conv.t = t; +#if defined(SOME_ARM) + // ARM ABI says the bit is in bsaeoffs instead, and that the value is shiffted left 1. + // This because valid ARM pointers may have the LSB set, so the "is virtual" bit had to be moved. + if (conv.u.baseoffs & 1) + return std::pair(conv.u.baseoffs / (sizeof(void*) * 2), conv.u.value / sizeof(void *)); +#else + // simple Itanium ABI implementation, used by everything but Microsoft and embedded EDG-based compilers + if (conv.u.value & 1) + return std::pair(conv.u.baseoffs / sizeof(void*), conv.u.value / sizeof(void *)); +#endif + +#elif defined(_MSC_VER) + union { + T t; + struct + { + unsigned char *value; + unsigned long baseoffs; + } u; + } conv; + conv.t = t; + + int value = virtual_function_index<0>((unsigned char *)conv.u.value); + if (value != -1) + return std::pair((int)(conv.u.baseoffs/sizeof(void*)), value); +#elif defined(__EDG__) + union { + T t; + struct { + short delta; + short vindex; + long vtordisp; + } u; + } conv; + conv.t = t; + + if (conv.u.vindex != 0) + return std::pair((conv.u.delta + conv.u.vtordisp)/sizeof(void*), conv.u.vindex * 2 + 1); +#else +#error No virtual indexing found for this compiler! Please contact the maintainers of HippoMocks +#endif + + return std::pair(-1, 0); +} + +template +T getNonvirtualMemberFunctionAddress(U u) +{ +#ifdef __EDG__ + // Edison Design Group C++ frontend (Comeau, Portland Group, Greenhills, etc) + union { + struct { + short delta; + short vindex; + T t; + } mfp_structure; + U u; + } conv; +#else + // Visual Studio, GCC, others + union { + struct { + T t; + } mfp_structure; + U u; + } conv; +#endif + conv.u = u; + return conv.mfp_structure.t; +} + +class TypeDestructable { +public: + virtual ~TypeDestructable() {} +}; + +template +class MemberWrap : public TypeDestructable { +private: + A *member; +public: + MemberWrap(A *mem) + : member(mem) + { + new (member) A(); + } + ~MemberWrap() + { + member->~A(); + } +}; + +// mock types +template +class mock : public base_mock +{ + typedef void (*funcptr)(); + friend class MockRepository; + unsigned char remaining[sizeof(T)]; + void NotImplemented() { + mock *realMock = getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repository = realMock->repo; + RAISEEXCEPTION(:: HM_NS NotImplementedException(repository)); + } +protected: + std::map funcTables; + void (*notimplementedfuncs[VIRT_FUNC_LIMIT])(); +public: + bool isZombie; + std::list members; + MockRepository *repo; + std::map, int> funcMap; + mock(MockRepository *repository) + : isZombie(false) + , repo(repository) + { + for (int i = 0; i < VIRT_FUNC_LIMIT; i++) + { + notimplementedfuncs[i] = getNonvirtualMemberFunctionAddress(&mock::NotImplemented); + } + funcptr *funcTable = new funcptr[VIRT_FUNC_LIMIT+2]; + memcpy(funcTable, notimplementedfuncs, sizeof(funcptr) * VIRT_FUNC_LIMIT); + ((void **)funcTable)[VIRT_FUNC_LIMIT] = this; + ((void **)funcTable)[VIRT_FUNC_LIMIT+1] = *(void **)this; + funcTables[0] = funcTable; + *(void **)this = funcTable; + for (unsigned int i = 1; i < sizeof(remaining) / sizeof(funcptr); i++) + { + ((void **)this)[i] = (void *)notimplementedfuncs; + } + } + ~mock() + { + for (std::list::iterator i = members.begin(); i != members.end(); ++i) + { + delete *i; + } + for (std::map::iterator i = funcTables.begin(); i != funcTables.end(); ++i) + { + delete [] i->second; + } + } + void mock_reset() + { + MockRepository *repository = this->repo; + // ugly but simple + this->~mock(); + new (this) mock(repository); + } + mock *getRealThis() + { + void ***base = (void ***)this; + return (mock *)((*base)[VIRT_FUNC_LIMIT]); + } + std::pair translateX(int x) + { + for (std::map, int>::iterator i = funcMap.begin(); i != funcMap.end(); ++i) + { + if (i->second == x+1) return i->first; + } + return std::pair(-1, 0); + } + template + void mockedDestructor(int); +}; + +// Do() function wrapping +class VirtualDestructable { public: virtual ~VirtualDestructable() {} }; + +template +class TupleInvocable : public VirtualDestructable +{ +public: + virtual Y operator()(const base_tuple &tupl) = 0; +}; + +template +class Invocable : public TupleInvocable +{ +public: + virtual Y operator()(A a = A(), B b = B(), C c = C(), D d = D(), E e = E(), F f = F(), G g = G(), H h = H(), I i = I(), J j = J(), K k = K(), L l = L(), M m = M(), N n = N(), O o = O(), P p = P()) = 0; + virtual Y operator()(const base_tuple &tupl) { + const ref_tuple &rTupl = reinterpret_cast &>(tupl); + return (*this)(rTupl.a, rTupl.b, rTupl.c, rTupl.d, rTupl.e, rTupl.f, rTupl.g, rTupl.h, + rTupl.i, rTupl.j, rTupl.k, rTupl.l, rTupl.m, rTupl.n, rTupl.o, rTupl.p); + } +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + return t(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j,k,l,m,n); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j,k,l,m); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j,k,l); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j,k); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i,j); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable{ + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, I i, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h,i); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, H h, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g,h); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, G g, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f,g); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, F f, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e,f); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, E e, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d,e); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, D d, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c,d); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, C c, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b,c); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, B b, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a,b); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(A a, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(a); + } + using Invocable::operator(); +}; +template +class DoWrapper : public Invocable { + T t; +public: + DoWrapper(T templ) : t(templ) {} + virtual Y operator()(NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType, NullType) + { + return t(); + } + using Invocable::operator(); +}; + +class ReturnValueHolder { +public: + virtual ~ReturnValueHolder() {} +}; + +template +class ReturnValueWrapper : public ReturnValueHolder { +public: + virtual T value() = 0; +}; + +template +class ReturnValueWrapperCopy : public ReturnValueWrapper { +public: + typename no_cref::type rv; + ReturnValueWrapperCopy(T retValue) : rv(retValue) {} + virtual T value() { return rv; }; +}; + +template +class ReturnValueWrapperRef : public ReturnValueWrapper { +public: + T rv; + ReturnValueWrapperRef(T retValue) : rv(retValue) {} + virtual T value() { return rv; }; +}; + +//Call wrapping +class Call { +public: + virtual bool matchesArgs(const base_tuple &tuple) = 0; + virtual void assignArgs(base_tuple &tuple) = 0; + ReturnValueHolder *retVal; +#ifndef HM_NO_EXCEPTIONS + ExceptionHolder *eHolder; +#endif + base_mock *mock; + VirtualDestructable *functor; + VirtualDestructable *matchFunctor; + std::pair funcIndex; + std::list previousCalls; + unsigned called; + RegistrationType expectation; + bool satisfied; + int lineno; + const char *funcName; + const char *fileName; +protected: + Call(RegistrationType expect, base_mock *baseMock, const std::pair &index, int X, const char *func, const char *file) + : retVal(0), +#ifndef HM_NO_EXCEPTIONS + eHolder(0), +#endif + mock(baseMock), + functor(0), + matchFunctor(0), + funcIndex(index), + called( 0 ), + expectation(expect), + satisfied(false), + lineno(X), + funcName(func), + fileName(file) + { + } +public: + virtual const base_tuple *getArgs() const = 0; + virtual ~Call() + { +#ifndef HM_NO_EXCEPTIONS + delete eHolder; +#endif + delete functor; + delete matchFunctor; + delete retVal; + } +}; + +std::ostream &operator<<(std::ostream &os, const Call &call); + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n, const CO & o, const CP & p) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n, const CO & o, const CP & p) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n, const CO & o) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n, const CO & o) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m, const CN & n) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l, const CM & m) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k, const CL & l) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,l,NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j, const CK & k) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,k,NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i, const CJ & j) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,j,NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h, const CI & i) { + args = new copy_tuple(a,b,c,d,e,f,g,h,i,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h) { + args = new copy_tuple(a,b,c,d,e,f,g,h,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g, const CH & h) { + args = new copy_tuple(a,b,c,d,e,f,g,h,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g) { + args = new copy_tuple(a,b,c,d,e,f,g,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f, const CG & g) { + args = new copy_tuple(a,b,c,d,e,f,g,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f) { + args = new copy_tuple(a,b,c,d,e,f,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e, const CF & f) { + args = new copy_tuple(a,b,c,d,e,f,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e) { + args = new copy_tuple(a,b,c,d,e,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d, const CE & e) { + args = new copy_tuple(a,b,c,d,e,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d) { + args = new copy_tuple(a,b,c,d,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c, const CD & d) { + args = new copy_tuple(a,b,c,d,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c) { + args = new copy_tuple(a,b,c,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b, const CC & c) { + args = new copy_tuple(a,b,c,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b) { + args = new copy_tuple(a,b,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a, const CB & b) { + args = new copy_tuple(a,b,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA & a) { + args = new copy_tuple(a,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file), args(0) {} + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &tupl) { + return (!args && !matchFunctor) || + (args && (*args == reinterpret_cast &>(tupl))) || + (matchFunctor && (*(TupleInvocable *)(matchFunctor))(tupl)); + } + void assignArgs(base_tuple &tupl) { + if(args) { + args->assign_to(static_cast &>(tupl)); + args->assign_from(static_cast &>(tupl)); + } + } + template + TCall &With(const CA &a) { + args = new copy_tuple(a,NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + return *this; + } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + template + TCall &Match(T function) { matchFunctor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file) { + args = new copy_tuple + (NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + } + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &) { return true; } + void assignArgs(base_tuple &) {} + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } + Call &Return(Y obj) { retVal = new ReturnValueWrapperCopy(obj); return *this; } + Call &ReturnByRef(Y obj) { retVal = new ReturnValueWrapperRef(obj); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; +template <> +class TCall : public Call { +private: + ref_comparable_assignable_tuple *args; +public: + const base_tuple *getArgs() const { return args; } + TCall(RegistrationType expect, base_mock *baseMock, std::pair index, int X, const char *func, const char *file) : Call(expect, baseMock, index, X, func ,file) { + args = new copy_tuple + (NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType(),NullType()); + } + ~TCall() { delete args; } + bool matchesArgs(const base_tuple &) { return true; } + void assignArgs(base_tuple &) { } + TCall &After(Call &call) { + previousCalls.push_back(&call); + return *this; + } + template + TCall &Do(T function) { functor = new DoWrapper(function); return *this; } +#ifndef HM_NO_EXCEPTIONS + template + Call &Throw(Ex exception) { eHolder = new ExceptionWrapper(exception); return *this; } +#endif +}; + +template +class MockRepoInstanceHolder { +public: + static MockRepository *instance; +}; + +template +MockRepository *MockRepoInstanceHolder::instance; + +inline +bool satisfied( std::list const& previousCalls ) +{ + for (std::list::const_iterator callsBefore = previousCalls.begin(); + callsBefore != previousCalls.end(); ++callsBefore) + { + if (!(*callsBefore)->satisfied) + { + return false; + } + } + return true; +} + + +class MockRepository { +private: + friend inline std::ostream &operator<<(std::ostream &os, const MockRepository &repo); + std::list mocks; + std::map staticFuncMap; +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + std::list staticReplaces; +#endif + + std::list neverCalls; + std::list expectations; + std::list optionals; +public: + bool autoExpect; +private: + + void addAutoExpectTo( Call* call ) + { + if (autoExpect && expectations.size() > 0) + { + call->previousCalls.push_back(expectations.back()); + } + } + + + void addCall( Call* call, RegistrationType expect ) + { + if( expect == Never ) { + addAutoExpectTo( call ); + neverCalls.push_back(call); + } + else if( expect.minimum == expect.maximum ) + { + addAutoExpectTo( call ); + expectations.push_back(call); + } + else + { + optionals.push_back(call); + } + } + +#ifndef HM_NO_EXCEPTIONS + ExceptionHolder *latentException; +#endif +public: +#ifndef HM_NO_EXCEPTIONS + void SetLatentException(ExceptionHolder *holder) + { + latentException = holder; + } +#endif +#ifdef _MSC_VER +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#define OnCallFunc(func) RegisterExpect_<__COUNTER__>(&func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallFunc(func) RegisterExpect_<__COUNTER__>(&func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallFunc(func) RegisterExpect_<__COUNTER__>(&func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallFuncOverload(func) RegisterExpect_<__COUNTER__>(func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallFuncOverload(func) RegisterExpect_<__COUNTER__>(func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallFuncOverload(func) RegisterExpect_<__COUNTER__>(func, HM_NS Never, #func, __FILE__, __LINE__) +#endif +#define OnCall(obj, func) RegisterExpect_<__COUNTER__>(obj, &func, HM_NS Any, #func, __FILE__, __LINE__) +#define OnCalls(obj, func, minimum) RegisterExpect_<__COUNTER__>(obj, &func, HM_NS RegistrationType(minimum,(std::numeric_limits::max)()), #func, __FILE__, __LINE__) +#define ExpectCall(obj, func) RegisterExpect_<__COUNTER__>(obj, &func, HM_NS Once, #func, __FILE__, __LINE__) +#define ExpectCalls(obj, func, num) RegisterExpect_<__COUNTER__>(obj, &func, HM_NS RegistrationType(num,num), #func, __FILE__, __LINE__) +#define NeverCall(obj, func) RegisterExpect_<__COUNTER__>(obj, &func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallOverload(obj, func) RegisterExpect_<__COUNTER__>(obj, func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallOverload(obj, func) RegisterExpect_<__COUNTER__>(obj, func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallOverload(obj, func) RegisterExpect_<__COUNTER__>(obj, func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallDestructor(obj) RegisterExpectDestructor<__COUNTER__>(obj, HM_NS Any, __FILE__, __LINE__) +#define ExpectCallDestructor(obj) RegisterExpectDestructor<__COUNTER__>(obj, HM_NS Once, __FILE__, __LINE__) +#define NeverCallDestructor(obj) RegisterExpectDestructor<__COUNTER__>(obj, HM_NS Never, __FILE__, __LINE__) +#else +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +#define OnCallFunc(func) RegisterExpect_<__LINE__>(&func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallFunc(func) RegisterExpect_<__LINE__>(&func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallFunc(func) RegisterExpect_<__LINE__>(&func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallFuncOverload(func) RegisterExpect_<__LINE__>(func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallFuncOverload(func) RegisterExpect_<__LINE__>(func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallFuncOverload(func) RegisterExpect_<__LINE__>(func, HM_NS Never, #func, __FILE__, __LINE__) +#endif +#define OnCall(obj, func) RegisterExpect_<__LINE__>(obj, &func, HM_NS Any, #func, __FILE__, __LINE__) +#define OnCalls(obj, func, minimum) RegisterExpect_<__LINE__>(obj, &func, HM_NS RegistrationType(minimum,(std::numeric_limits::max)()), #func, __FILE__, __LINE__) +#define ExpectCall(obj, func) RegisterExpect_<__LINE__>(obj, &func, HM_NS Once, #func, __FILE__, __LINE__) +#define ExpectCalls(obj, func, num) RegisterExpect_<__LINE__>(obj, &func, HM_NS RegistrationType(num,num), #func, __FILE__, __LINE__) +#define NeverCall(obj, func) RegisterExpect_<__LINE__>(obj, &func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallOverload(obj, func) RegisterExpect_<__LINE__>(obj, func, HM_NS Any, #func, __FILE__, __LINE__) +#define ExpectCallOverload(obj, func) RegisterExpect_<__LINE__>(obj, func, HM_NS Once, #func, __FILE__, __LINE__) +#define NeverCallOverload(obj, func) RegisterExpect_<__LINE__>(obj, func, HM_NS Never, #func, __FILE__, __LINE__) +#define OnCallDestructor(obj) RegisterExpectDestructor<__LINE__>(obj, HM_NS Any, __FILE__, __LINE__) +#define ExpectCallDestructor(obj) RegisterExpectDestructor<__LINE__>(obj, HM_NS Once, __FILE__, __LINE__) +#define NeverCallDestructor(obj) RegisterExpectDestructor<__LINE__>(obj, HM_NS Never, __FILE__, __LINE__) +#endif + template + void Member(A *mck, C B::*member) + { + C A::*realMember = (C A::*)member; + C *realRealMember = &(mck->*realMember); + mock *realMock = (mock *)mck; + realMock->members.push_back(new MemberWrap(realRealMember)); + } + template + TCall &RegisterExpectDestructor(Z2 *mck, RegistrationType expect, const char *fileName, unsigned long lineNo); + +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + template + TCall &RegisterExpect_(Y (*func)(), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + +#if defined(_MSC_VER) && !defined(_WIN64) + template + TCall &RegisterExpect_(Y (__stdcall *func)(), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); +#endif +#endif + + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + + //GCC 3.x doesn't seem to understand overloading on const or non-const member function. Volatile appears to work though. +#if !defined(__GNUC__) || __GNUC__ > 3 + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)() volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } + + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)() const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } + + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)() const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) + { return RegisterExpect_(mck, (Y(Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) + { return RegisterExpect_(mck, (Y(Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) + { return RegisterExpect_(mck, (Y(Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } +#endif + +#if defined(_MSC_VER) && !defined(_WIN64) + // COM only support - you can duplicate this for cdecl and fastcall if you want to, but those are not as common as COM. + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::* func)(), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo); + + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)() volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } + + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)() const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) const volatile, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } + + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)() const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)())(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))(func), expect, functionName ,fileName, lineNo); } + template + TCall &RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) const, RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) { return RegisterExpect_(mck, (Y(__stdcall Z::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))(func), expect, functionName ,fileName, lineNo); } +#endif + + + template + void BasicRegisterExpect(mock *zMock, int baseOffset, int funcIndex, void (base_mock::*func)(), int X); +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + int BasicStaticRegisterExpect(void (*func)(), void (*fp)(), int X) + { + if (staticFuncMap.find(func) == staticFuncMap.end()) + { + staticFuncMap[func] = X; + staticReplaces.push_back(new Replace(func, fp)); + } + return staticFuncMap[func]; + } +#endif + + void doCall( Call* call, const base_tuple &tuple ) + { + ++call->called; + + call->satisfied = call->called >= call->expectation.minimum; + + call->assignArgs(const_cast(tuple)); + #ifndef HM_NO_EXCEPTIONS + if (call->eHolder) + call->eHolder->rethrow(); + #endif + } + + void doVoidFunctor( Call* call, const base_tuple &tuple ) + { + if (call->functor != NULL) + (*(TupleInvocable *)(call->functor))(tuple); + } + + template + Z doReturnFunctor( Call* call, const base_tuple &tuple ) + { + if (call->functor != NULL) + { + if(call->retVal == NULL) + { + return (*(TupleInvocable *)(call->functor))(tuple); + } + else + { + (*(TupleInvocable *)(call->functor))(tuple); + } + } + + if (call->retVal) + return ((ReturnValueWrapper *)call->retVal)->value(); + + RAISEEXCEPTION(NoResultSetUpException(this, call->getArgs(), call->funcName)); + } + + void doVoidCall( Call* call, const base_tuple &tuple, bool const makeLatent ) + { + if( call->called < call->expectation.maximum ) + { + doCall( call, tuple ); + doVoidFunctor( call, tuple ); + } + else + { + doThrow( call, makeLatent ); + } + } + + template + Z doReturnCall( Call* call, const base_tuple &tuple ) + { + if( call->called < call->expectation.maximum ) + { + doCall( call, tuple ); + return doReturnFunctor( call, tuple ); + } + RAISEEXCEPTION(ExpectationException(this, call->getArgs(), call->funcName)); + } + + + void doThrow( Call * call, bool const makeLatent ) + { + call->satisfied = true; + + if (makeLatent) + { + #ifndef HM_NO_EXCEPTIONS + if (latentException) + return; + #endif + RAISELATENTEXCEPTION(ExpectationException(this, call->getArgs(), call->funcName)); + } + else + { + RAISEEXCEPTION(ExpectationException(this, call->getArgs(), call->funcName)); + } + } + + const char *funcName( base_mock *mock, std::pair funcno ) + { + const char *name = NULL; + for (std::list::iterator i = expectations.begin(); i != expectations.end() && !name; ++i) + { + Call *call = *i; + if (call->mock == mock && + call->funcIndex == funcno) + name = call->funcName; + } + for (std::list::iterator i = optionals.begin(); i != optionals.end() && !name; ++i) + { + Call *call = *i; + if (call->mock == mock && + call->funcIndex == funcno) + name = call->funcName; + } + for (std::list::iterator i = neverCalls.begin(); i != neverCalls.end() && !name; ++i) + { + Call *call = *i; + if (call->mock == mock && + call->funcIndex == funcno) + name = call->funcName; + } + return name; + } + + bool + matches( Call *call, base_mock *mock, std::pair funcno, const base_tuple &tuple ) + { + return call->mock == mock && + call->funcIndex == funcno && + call->matchesArgs(tuple) && + satisfied( call->previousCalls ); + + } + + bool + isUnsatisfied( Call *call, base_mock *mock, std::pair funcno, const base_tuple &tuple ) + { + return ! call->satisfied && matches( call, mock, funcno, tuple ); + } + + template + Z DoExpectation(base_mock *mock, std::pair funcno, const base_tuple &tuple); + + void DoVoidExpectation(base_mock *mock, std::pair funcno, const base_tuple &tuple, bool makeLatent = false) + { + for (std::list::reverse_iterator i = neverCalls.rbegin(); i != neverCalls.rend(); ++i) + { + Call *call = *i; + if ( matches( call, mock, funcno, tuple ) ) + { + doThrow( call, makeLatent ); + return; + } + } + for (std::list::reverse_iterator i = expectations.rbegin(); i != expectations.rend(); ++i) + { + Call *call = *i; + if ( isUnsatisfied( call, mock, funcno, tuple ) ) + { + doVoidCall( call, tuple, makeLatent ); + return; + } + } + for (std::list::reverse_iterator i = optionals.rbegin(); i != optionals.rend(); ++i) + { + Call *call = *i; + if ( matches( call, mock, funcno, tuple ) ) + { + doVoidCall( call, tuple, makeLatent ); + return; + } + } + + if (makeLatent) + { +#ifndef HM_NO_EXCEPTIONS + if (latentException) + return; +#endif + RAISELATENTEXCEPTION(ExpectationException(this, &tuple, funcName(mock, funcno))); + } + else + { + RAISEEXCEPTION(ExpectationException(this, &tuple, funcName(mock, funcno))); + } + } + MockRepository() + : autoExpect(DEFAULT_AUTOEXPECT) +#ifndef HM_NO_EXCEPTIONS + , latentException(0) +#endif + { + MockRepoInstanceHolder<0>::instance = this; + } + ~MockRepository() + // If we're on a recent enough compiler that's not VS2012 (as it doesn't have noexcept) +#if __cplusplus > 199711L && (!defined(_MSC_VER) || _MSC_VER > 1700) +noexcept(false) +#endif + { + MockRepoInstanceHolder<0>::instance = 0; +#ifndef HM_NO_EXCEPTIONS + if (!std::uncaught_exception()) + { + try + { +#endif + VerifyAll(); +#ifndef HM_NO_EXCEPTIONS + } + catch(...) + { + delete latentException; + reset(); + for (std::list::iterator i = mocks.begin(); i != mocks.end(); i++) + { + (*i)->destroy(); + } +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + for (std::list::iterator i = staticReplaces.begin(); i != staticReplaces.end(); i++) + { + delete *i; + } +#endif + throw; + } + } + if (latentException) + { + try + { + latentException->rethrow(); + } + catch(BASE_EXCEPTION e) + { + printf("Latent exception masked!\nException:\n%s\n", e.what()); + } + delete latentException; + } +#endif + reset(); + for (std::list::iterator i = mocks.begin(); i != mocks.end(); i++) + { + (*i)->destroy(); + } +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT + for (std::list::iterator i = staticReplaces.begin(); i != staticReplaces.end(); i++) + { + delete *i; + } +#endif + } + void reset() + { + for (std::list::iterator i = expectations.begin(); i != expectations.end(); i++) + { + delete *i; + } + expectations.clear(); + for (std::list::iterator i = neverCalls.begin(); i != neverCalls.end(); i++) + { + delete *i; + } + neverCalls.clear(); + for (std::list::iterator i = optionals.begin(); i != optionals.end(); i++) + { + delete *i; + } + optionals.clear(); + for (std::list::iterator i = mocks.begin(); i != mocks.end(); i++) + { + (*i)->reset(); + } + } + + void VerifyAll() + { +#ifndef HM_NO_EXCEPTIONS + if (latentException) + latentException->rethrow(); +#endif + + for (std::list::iterator i = expectations.begin(); i != expectations.end(); i++) + { + if (!(*i)->satisfied) { + RAISEEXCEPTION(CallMissingException(this)); + } + } + } + void VerifyPartial(base_mock *obj) + { +#ifndef HM_NO_EXCEPTIONS + if (latentException) + return; +#endif + for (std::list::iterator i = expectations.begin(); i != expectations.end(); i++) + { + if ((*i)->mock == (base_mock *)obj && + !(*i)->satisfied ) + { + RAISELATENTEXCEPTION(CallMissingException(this)); + } + } + } + template + base *Mock(); +}; + +// mock function providers +template +class mockFuncs : public mock { +private: + mockFuncs(); +public: + template + Y expectation0() + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple<>()); + } + template + Y expectation1(A a) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a)); + } + template + Y expectation2(A a, B b) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b)); + } + template + Y expectation3(A a, B b, C c) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c)); + } + template + Y expectation4(A a, B b, C c, D d) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d)); + } + template + Y expectation5(A a, B b, C c, D d, E e) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e)); + } + template + Y expectation6(A a, B b, C c, D d, E e, F f) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f)); + } + template + Y expectation7(A a, B b, C c, D d, E e, F f, G g) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g)); + } + template + Y expectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + Y expectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + Y expectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + Y expectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + Y expectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + Y expectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + Y expectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + Y expectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + Y expectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + return repo->template DoExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } + + template + static Y static_expectation0() + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple<>()); + } + template + static Y static_expectation1(A a) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a)); + } + template + static Y static_expectation2(A a, B b) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b)); + } + template + static Y static_expectation3(A a, B b, C c) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c)); + } + template + static Y static_expectation4(A a, B b, C c, D d) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d)); + } + template + static Y static_expectation5(A a, B b, C c, D d, E e) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e)); + } + template + static Y static_expectation6(A a, B b, C c, D d, E e, F f) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f)); + } + template + static Y static_expectation7(A a, B b, C c, D d, E e, F f, G g) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g)); + } + template + static Y static_expectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + static Y static_expectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + static Y static_expectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + static Y static_expectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + static Y static_expectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + static Y static_expectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + static Y static_expectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + static Y static_expectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + static Y static_expectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } + +#ifdef _MSC_VER + template + Y __stdcall stdcallexpectation0() + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple<>()); + } + template + Y __stdcall stdcallexpectation1(A a) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a)); + } + template + Y __stdcall stdcallexpectation2(A a, B b) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b)); + } + template + Y __stdcall stdcallexpectation3(A a, B b, C c) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c)); + } + template + Y __stdcall stdcallexpectation4(A a, B b, C c, D d) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d)); + } + template + Y __stdcall stdcallexpectation5(A a, B b, C c, D d, E e) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e)); + } + template + Y __stdcall stdcallexpectation6(A a, B b, C c, D d, E e, F f) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f)); + } + template + Y __stdcall stdcallexpectation7(A a, B b, C c, D d, E e, F f, G g) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g)); + } + template + Y __stdcall stdcallexpectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + Y __stdcall stdcallexpectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + Y __stdcall stdcallexpectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + Y __stdcall stdcallexpectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + Y __stdcall stdcallexpectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + Y __stdcall stdcallexpectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + Y __stdcall stdcallexpectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + Y __stdcall stdcallexpectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + Y __stdcall stdcallexpectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + MockRepository *repo = mock::repo; + return repo->template DoExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } +#if defined(_MSC_VER) && !defined(_WIN64) + template + static Y __stdcall static_stdcallexpectation0() + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple<>()); + } + template + static Y __stdcall static_stdcallexpectation1(A a) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a)); + } + template + static Y __stdcall static_stdcallexpectation2(A a, B b) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b)); + } + template + static Y __stdcall static_stdcallexpectation3(A a, B b, C c) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c)); + } + template + static Y __stdcall static_stdcallexpectation4(A a, B b, C c, D d) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d)); + } + template + static Y __stdcall static_stdcallexpectation5(A a, B b, C c, D d, E e) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e)); + } + template + static Y __stdcall static_stdcallexpectation6(A a, B b, C c, D d, E e, F f) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f)); + } + template + static Y __stdcall static_stdcallexpectation7(A a, B b, C c, D d, E e, F f, G g) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g)); + } + template + static Y __stdcall static_stdcallexpectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + static Y __stdcall static_stdcallexpectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + static Y __stdcall static_stdcallexpectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + static Y __stdcall static_stdcallexpectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + static Y __stdcall static_stdcallexpectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + static Y __stdcall static_stdcallexpectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + static Y __stdcall static_stdcallexpectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + static Y __stdcall static_stdcallexpectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + static Y __stdcall static_stdcallexpectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + return MockRepoInstanceHolder<0>::instance->template DoExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } +#endif +#endif +}; + +template +class mockFuncs : public mock { +private: + mockFuncs(); +public: + template + void expectation0() + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple<>()); + } + template + void expectation1(A a) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a)); + } + template + void expectation2(A a, B b) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b)); + } + template + void expectation3(A a, B b, C c) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c)); + } + template + void expectation4(A a, B b, C c, D d) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d)); + } + template + void expectation5(A a, B b, C c, D d, E e) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e)); + } + template + void expectation6(A a, B b, C c, D d, E e, F f) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f)); + } + template + void expectation7(A a, B b, C c, D d, E e, F f, G g) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g)); + } + template + void expectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + void expectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + void expectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + void expectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + void expectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + void expectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + void expectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + void expectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + void expectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + mock *realMock = mock::getRealThis(); + if (realMock->isZombie) + RAISEEXCEPTION(ZombieMockException(realMock->repo)); + MockRepository *repo = realMock->repo; + repo->DoVoidExpectation(realMock, realMock->translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } + template + static void static_expectation0() + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple<>()); + } + template + static void static_expectation1(A a) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a)); + } + template + static void static_expectation2(A a, B b) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b)); + } + template + static void static_expectation3(A a, B b, C c) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c)); + } + template + static void static_expectation4(A a, B b, C c, D d) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d)); + } + template + static void static_expectation5(A a, B b, C c, D d, E e) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e)); + } + template + static void static_expectation6(A a, B b, C c, D d, E e, F f) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f)); + } + template + static void static_expectation7(A a, B b, C c, D d, E e, F f, G g) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g)); + } + template + static void static_expectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + static void static_expectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + static void static_expectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + static void static_expectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + static void static_expectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + static void static_expectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + static void static_expectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + static void static_expectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + static void static_expectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } + +#ifdef _MSC_VER + template + void __stdcall stdcallexpectation0() + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple<>()); + } + template + void __stdcall stdcallexpectation1(A a) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a)); + } + template + void __stdcall stdcallexpectation2(A a, B b) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b)); + } + template + void __stdcall stdcallexpectation3(A a, B b, C c) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c)); + } + template + void __stdcall stdcallexpectation4(A a, B b, C c, D d) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d)); + } + template + void __stdcall stdcallexpectation5(A a, B b, C c, D d, E e) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e)); + } + template + void __stdcall stdcallexpectation6(A a, B b, C c, D d, E e, F f) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f)); + } + template + void __stdcall stdcallexpectation7(A a, B b, C c, D d, E e, F f, G g) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g)); + } + template + void __stdcall stdcallexpectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + void __stdcall stdcallexpectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + void __stdcall stdcallexpectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + void __stdcall stdcallexpectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + void __stdcall stdcallexpectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + void __stdcall stdcallexpectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + void __stdcall stdcallexpectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + void __stdcall stdcallexpectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + void __stdcall stdcallexpectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + MockRepository *repo = mock::repo; + repo->DoVoidExpectation(this, mock::translateX(X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } +#if defined(_MSC_VER) && !defined(_WIN64) + template + static void __stdcall static_stdcallexpectation0() + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple<>()); + } + template + static void __stdcall static_stdcallexpectation1(A a) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a)); + } + template + static void __stdcall static_stdcallexpectation2(A a, B b) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b)); + } + template + static void __stdcall static_stdcallexpectation3(A a, B b, C c) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c)); + } + template + static void __stdcall static_stdcallexpectation4(A a, B b, C c, D d) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d)); + } + template + static void __stdcall static_stdcallexpectation5(A a, B b, C c, D d, E e) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e)); + } + template + static void __stdcall static_stdcallexpectation6(A a, B b, C c, D d, E e, F f) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f)); + } + template + static void __stdcall static_stdcallexpectation7(A a, B b, C c, D d, E e, F f, G g) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g)); + } + template + static void __stdcall static_stdcallexpectation8(A a, B b, C c, D d, E e, F f, G g, H h) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h)); + } + template + static void __stdcall static_stdcallexpectation9(A a, B b, C c, D d, E e, F f, G g, H h, I i) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i)); + } + template + static void __stdcall static_stdcallexpectation10(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j)); + } + template + static void __stdcall static_stdcallexpectation11(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k)); + } + template + static void __stdcall static_stdcallexpectation12(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l)); + } + template + static void __stdcall static_stdcallexpectation13(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m)); + } + template + static void __stdcall static_stdcallexpectation14(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n)); + } + template + static void __stdcall static_stdcallexpectation15(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)); + } + template + static void __stdcall static_stdcallexpectation16(A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l, M m, N n, O o, P p) + { + return MockRepoInstanceHolder<0>::instance->DoVoidExpectation(NULL, std::pair(0, X), ref_tuple(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)); + } +#endif +#endif +}; + +template +template +void mock::mockedDestructor(int) +{ + repo->DoVoidExpectation(this, translateX(X), ref_tuple<>(), true); + repo->VerifyPartial(this); + isZombie = true; +} + +template +void MockRepository::BasicRegisterExpect(mock *zMock, int baseOffset, int funcIndex, void (base_mock::*func)(), int X) +{ + if (funcIndex > VIRT_FUNC_LIMIT) RAISEEXCEPTION(NotImplementedException(this)); + if ((unsigned int)baseOffset * sizeof(void*) + sizeof(void*)-1 > sizeof(Z)) RAISEEXCEPTION(NotImplementedException(this)); + if (zMock->funcMap.find(std::make_pair(baseOffset, funcIndex)) == zMock->funcMap.end()) + { + if (zMock->funcTables.find(baseOffset) == zMock->funcTables.end()) + { + typedef void (*funcptr)(); + funcptr *funcTable = new funcptr[VIRT_FUNC_LIMIT+1]; + memcpy(funcTable, zMock->notimplementedfuncs, sizeof(funcptr) * VIRT_FUNC_LIMIT); + ((void **)funcTable)[VIRT_FUNC_LIMIT] = zMock; + zMock->funcTables[baseOffset] = funcTable; + ((void **)zMock)[baseOffset] = funcTable; + } + zMock->funcMap[std::make_pair(baseOffset, funcIndex)] = X+1; + zMock->funcTables[baseOffset][funcIndex] = getNonvirtualMemberFunctionAddress(func); + } +} + +template +TCall &MockRepository::RegisterExpectDestructor(Z2 *mck, RegistrationType expect, const char *fileName, unsigned long lineNo) +{ + func_index idx; + ((Z2 *)&idx)->~Z2(); + int funcIndex = idx.lci * FUNCTION_STRIDE + FUNCTION_BASE; + void (mock::*member)(int); + member = &mock::template mockedDestructor; + BasicRegisterExpect(reinterpret_cast *>(mck), + 0, funcIndex, + reinterpret_cast(member), X); +#ifdef EXTRA_DESTRUCTOR + BasicRegisterExpect(reinterpret_cast *>(mck), + 0, funcIndex+1, + reinterpret_cast(member), X); +#endif + TCall *call = new TCall(Once, reinterpret_cast(mck), std::pair(0, funcIndex), lineNo, "destructor", fileName); + addCall( call, expect ); + return *call; +} + +#if defined(_MSC_VER) && !defined(_WIN64) +// Support for COM, see declarations +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)())func); + Y(__stdcall mockFuncs::*mfp)(); + mfp = &mockFuncs::template stdcallexpectation0; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A))func); + Y(__stdcall mockFuncs::*mfp)(A); + mfp = &mockFuncs::template stdcallexpectation1; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B))func); + Y(__stdcall mockFuncs::*mfp)(A, B); + mfp = &mockFuncs::template stdcallexpectation2; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C); + mfp = &mockFuncs::template stdcallexpectation3; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D); + mfp = &mockFuncs::template stdcallexpectation4; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E); + mfp = &mockFuncs::template stdcallexpectation5; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F); + mfp = &mockFuncs::template stdcallexpectation6; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G); + mfp = &mockFuncs::template stdcallexpectation7; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H); + mfp = &mockFuncs::template stdcallexpectation8; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I); + mfp = &mockFuncs::template stdcallexpectation9; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J); + mfp = &mockFuncs::template stdcallexpectation10; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K); + mfp = &mockFuncs::template stdcallexpectation11; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K, L))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K, L); + mfp = &mockFuncs::template stdcallexpectation12; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K, L, M))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K, L, M); + mfp = &mockFuncs::template stdcallexpectation13; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K, L, M, N))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K, L, M, N); + mfp = &mockFuncs::template stdcallexpectation14; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O); + mfp = &mockFuncs::template stdcallexpectation15; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} + +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (__stdcall Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(__stdcall Z2::*)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P))func); + Y(__stdcall mockFuncs::*mfp)(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P); + mfp = &mockFuncs::template stdcallexpectation16; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, + funcIndex.second, + reinterpret_cast(mfp), X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, funcName, fileName); + addCall( call, expect ); + return *call; +} +#endif + +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +template +TCall &MockRepository::RegisterExpect_(Y (*func)(), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(); + fp = &mockFuncs::template static_expectation0; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A); + fp = &mockFuncs::template static_expectation1; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B); + fp = &mockFuncs::template static_expectation2; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C); + fp = &mockFuncs::template static_expectation3; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D); + fp = &mockFuncs::template static_expectation4; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E); + fp = &mockFuncs::template static_expectation5; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F); + fp = &mockFuncs::template static_expectation6; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G); + fp = &mockFuncs::template static_expectation7; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H); + fp = &mockFuncs::template static_expectation8; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I); + fp = &mockFuncs::template static_expectation9; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J); + fp = &mockFuncs::template static_expectation10; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K); + fp = &mockFuncs::template static_expectation11; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K,L); + fp = &mockFuncs::template static_expectation12; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K,L,M); + fp = &mockFuncs::template static_expectation13; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N); + fp = &mockFuncs::template static_expectation14; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O); + fp = &mockFuncs::template static_expectation15; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} + +template +TCall &MockRepository::RegisterExpect_(Y (*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (*fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P); + fp = &mockFuncs::template static_expectation16; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} + +#if defined(_MSC_VER) && !defined(_WIN64) +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(); + fp = &mockFuncs::template static_stdcallexpectation0; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A); + fp = &mockFuncs::template static_stdcallexpectation1; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B); + fp = &mockFuncs::template static_stdcallexpectation2; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C); + fp = &mockFuncs::template static_stdcallexpectation3; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D); + fp = &mockFuncs::template static_stdcallexpectation4; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E); + fp = &mockFuncs::template static_stdcallexpectation5; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F); + fp = &mockFuncs::template static_stdcallexpectation6; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G); + fp = &mockFuncs::template static_stdcallexpectation7; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H); + fp = &mockFuncs::template static_stdcallexpectation8; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I); + fp = &mockFuncs::template static_stdcallexpectation9; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J); + fp = &mockFuncs::template static_stdcallexpectation10; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K); + fp = &mockFuncs::template static_stdcallexpectation11; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K,L); + fp = &mockFuncs::template static_stdcallexpectation12; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K,L,M); + fp = &mockFuncs::template static_stdcallexpectation13; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N); + fp = &mockFuncs::template static_stdcallexpectation14; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O); + fp = &mockFuncs::template static_stdcallexpectation15; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} + +template +TCall &MockRepository::RegisterExpect_(Y (__stdcall *func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *funcName, const char *fileName, unsigned long lineNo) +{ + Y (__stdcall *fp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P); + fp = &mockFuncs::template static_stdcallexpectation16; + int index = BasicStaticRegisterExpect(reinterpret_cast(func), reinterpret_cast(fp),X); + TCall *call = new TCall(expect, NULL, std::pair(0, index), lineNo, funcName ,fileName); + addCall( call, expect ); + return *call; +} +#endif +#endif + +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y (Z2::*)())func); + Y (mockFuncs::*mfp)(); + mfp = &mockFuncs::template expectation0; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A))func); + Y (mockFuncs::*mfp)(A); + mfp = &mockFuncs::template expectation1; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B))func); + Y (mockFuncs::*mfp)(A,B); + mfp = &mockFuncs::template expectation2; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C))func); + Y (mockFuncs::*mfp)(A,B,C); + mfp = &mockFuncs::template expectation3; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D))func); + Y (mockFuncs::*mfp)(A,B,C,D); + mfp = &mockFuncs::template expectation4; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E))func); + Y (mockFuncs::*mfp)(A,B,C,D,E); + mfp = &mockFuncs::template expectation5; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F); + mfp = &mockFuncs::template expectation6; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G); + mfp = &mockFuncs::template expectation7; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H); + mfp = &mockFuncs::template expectation8; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I); + mfp = &mockFuncs::template expectation9; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J); + mfp = &mockFuncs::template expectation10; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K); + mfp = &mockFuncs::template expectation11; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K,L))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K,L); + mfp = &mockFuncs::template expectation12; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K,L,M))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K,L,M); + mfp = &mockFuncs::template expectation13; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N); + mfp = &mockFuncs::template expectation14; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O); + mfp = &mockFuncs::template expectation15; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} + +template +TCall &MockRepository::RegisterExpect_(Z2 *mck, Y (Z::*func)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P), RegistrationType expect, const char *functionName, const char *fileName, unsigned long lineNo) +{ + std::pair funcIndex = virtual_index((Y(Z2::*)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P))func); + Y (mockFuncs::*mfp)(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P); + mfp = &mockFuncs::template expectation16; + BasicRegisterExpect(reinterpret_cast *>(mck), + funcIndex.first, funcIndex.second, + reinterpret_cast(mfp),X); + TCall *call = new TCall(expect, reinterpret_cast(mck), funcIndex, lineNo, functionName ,fileName); + addCall( call, expect ); + return *call; +} + +template +Z MockRepository::DoExpectation(base_mock *mock, std::pair funcno, const base_tuple &tuple) +{ + for (std::list::reverse_iterator i = neverCalls.rbegin(); i != neverCalls.rend(); ++i) + { + Call *call = *i; + if ( matches( call, mock, funcno, tuple ) ) + { + call->satisfied = true; + RAISEEXCEPTION(ExpectationException(this, call->getArgs(), call->funcName)); + } + } + for (std::list::reverse_iterator i = expectations.rbegin(); i != expectations.rend(); ++i) + { + Call *call = *i; + if( isUnsatisfied( call, mock, funcno, tuple ) ) + { + return doReturnCall( call, tuple ); + } + } + for (std::list::reverse_iterator i = optionals.rbegin(); i != optionals.rend(); ++i) + { + Call *call = *i; + if ( matches( call, mock, funcno, tuple ) ) + { + return doReturnCall( call, tuple ); + } + } + RAISEEXCEPTION(ExpectationException(this, &tuple, funcName(mock,funcno))); +} +template +base *MockRepository::Mock() { + mock *m = new mock(this); + mocks.push_back(m); + return reinterpret_cast(m); +} +inline std::ostream &operator<<(std::ostream &os, const Call &call) +{ + os << call.fileName << "(" << call.lineno << ") "; + if (call.expectation == Once) + os << "Expectation for "; + else + os << "Result set for "; + + os << call.funcName; + + if (call.getArgs()) + call.getArgs()->printTo(os); + else + os << "(...)"; + + os << " on the mock at 0x" << call.mock << " was "; + + if (!call.satisfied) + os << "not "; + + if (call.expectation == Once) + os << "satisfied." << std::endl; + else + os << "used." << std::endl; + + return os; +} + +inline std::ostream &operator<<(std::ostream &os, const MockRepository &repo) +{ + if (repo.expectations.size()) + { + os << "Expections set:" << std::endl; + for (std::list::const_iterator exp = repo.expectations.begin(); exp != repo.expectations.end(); ++exp) + os << **exp; + os << std::endl; + } + + if (repo.neverCalls.size()) + { + os << "Functions explicitly expected to not be called:" << std::endl; + for (std::list::const_iterator exp = repo.neverCalls.begin(); exp != repo.neverCalls.end(); ++exp) + os << **exp; + os << std::endl; + } + + if (repo.optionals.size()) + { + os << "Optional results set up:" << std::endl; + for (std::list::const_iterator exp = repo.optionals.begin(); exp != repo.optionals.end(); ++exp) + os << **exp; + os << std::endl; + } + return os; +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#ifndef NO_HIPPOMOCKS_NAMESPACE +} + +using HippoMocks::MockRepository; +using HippoMocks::DONTCARE_NAME; +using HippoMocks::Call; +using HippoMocks::Out; +using HippoMocks::In; +#endif + +#undef DEBUGBREAK +#undef BASE_EXCEPTION +#undef RAISEEXCEPTION +#undef RAISELATENTEXCEPTION +#undef DONTCARE_NAME +#undef VIRT_FUNC_LIMIT +#undef EXTRA_DESTRUCTOR +#undef FUNCTION_BASE +#undef FUNCTION_STRIDE +#undef CFUNC_MOCK_PLATFORMIS64BIT + +#endif + diff --git a/extlibs/hippomocks-master/HippoMocksTest/CMakeLists.txt b/extlibs/hippomocks-master/HippoMocksTest/CMakeLists.txt new file mode 100644 index 0000000..7837c1d --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.0) +project(HippoMocksTests CXX) +include_directories(../HippoMocks) + +set(test_SOURCES +Framework.cpp +is_virtual.cpp +main.cpp +test.cpp +test_args.cpp +test_array.cpp +test_autoptr.cpp +test_cfuncs.cpp +test_class_args.cpp +test_constref_params.cpp +test_cv_funcs.cpp +test_do.cpp +test_dontcare.cpp +test_except.cpp +test_exception_quality.cpp +test_filter.cpp +test_inparam.cpp +test_membermock.cpp +test_mi.cpp +test_nevercall.cpp +test_optional.cpp +test_outparam.cpp +test_overload.cpp +test_ref_args.cpp +test_regression_arg_count.cpp +test_retval.cpp +test_transaction.cpp +test_zombie.cpp) + +add_executable(HippoMocksTest ${test_SOURCES}) +add_test(test HippoMocksTest) + diff --git a/extlibs/hippomocks-master/HippoMocksTest/Framework.cpp b/extlibs/hippomocks-master/HippoMocksTest/Framework.cpp new file mode 100644 index 0000000..efa5bb4 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/Framework.cpp @@ -0,0 +1,37 @@ +#include "Framework.h" + +template <> +void check_equal(float a, float b, const char *sa, const char *sb) { + if (a != b) throw BaseException("%s(%f) != %s(%f)", sa, a, sb, b); +} + +template <> +void check_equal(const char *a, const char *b, const char *sa, const char *sb) { + if (strcmp(a, b) != 0) { throw BaseException("%s(%s) != %s(%s)", sa, a, sb, b); } +} + +bool TestRegistry::RunTests() { + char spinner[5] = "\\|/-"; + unsigned long i = 0, s = 0; + size_t spinidx = 0; + for (std::vector::iterator it = tests.begin(); it != tests.end(); ++it) { + Test *t = *it; + i++; + try { + t->Run(); + s++; + } catch (std::exception &e) { + printf("Test %s failed with exception: %s\n", t->name.c_str(), e.what()); + } catch (int e) { + printf("Test %s failed with error code: %d\n", t->name.c_str(), e); + } catch (...) { + printf("Test %s failed with ellipsis-caught error\n", t->name.c_str()); + } + printf("%c\r", spinner[spinidx]); + spinidx = (spinidx + 1) % 4; + } + printf("%lu of %lu tests successful\n", s, i); + return !(s == i); +} + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/Framework.h b/extlibs/hippomocks-master/HippoMocksTest/Framework.h new file mode 100644 index 0000000..12fb59a --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/Framework.h @@ -0,0 +1,82 @@ +#ifndef TEST_H +#define TEST_H + +#include +#include +#include +#include +#include +#include + +class BaseException : public std::exception { +public: + BaseException(std::string fmt, ...) { + va_list l; + static char buffer[4096]; + va_start(l, fmt); + vsnprintf(buffer, 4096, fmt.c_str(), l); + va_end(l); + error = buffer; + } + + ~BaseException() throw() {} + const char *what() const throw() { return error.c_str(); } +private: + std::string error; +}; + +class Test; + +class TestRegistry { + std::vector tests; +public: + static TestRegistry &Instance() { static TestRegistry registry; return registry; } + void AddTest(Test *test) { + tests.push_back(test); + } + bool RunTests(); +}; + +class Test { +public: + std::string name; + Test(std::string name) + : name(name) + { + } + virtual void Run() = 0; +}; + +template +void check_equal(T a, TB b, const char *sa, const char *sb) { + if (a != b) { + throw BaseException("%s(%d) != %s(%d)", sa, a, sb, b); + } +} + +template <> +void check_equal(float a, float b, const char *sa, const char *sb); + +template +void check_equal(const std::string &a, T b, const char *sa, const char *sb) { + return check_equal(a.c_str(), b, sa, sb); +} + +template +void check_equal(T a, const std::string &b, const char *sa, const char *sb) { + return check_equal(a, b.c_str(), sa, sb); +} + +template <> +void check_equal(const char *a, const char *b, const char *sa, const char *sb); + +#define CHECK(x) { if (!(x)) { throw BaseException("!(%s)", #x); } } +#define EQUALS(x, y) check_equal(x, y, #x, #y) + +#define TEST(X) class Test##X : public Test { public: Test##X() : Test(#X) { TestRegistry::Instance().AddTest(this); } void Run(); };\ +static Test##X _Test##X;\ +void Test##X::Run() + +#endif + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.dev b/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.dev new file mode 100644 index 0000000..e96bb3a --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.dev @@ -0,0 +1,169 @@ +[Project] +FileName=HippoMocks.dev +Name=HippoMocks +UnitCount=12 +Type=1 +Ver=1 +ObjFiles= +Includes= +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker= +IsCpp=1 +Icon= +ExeOutput= +ObjectOutput= +OverrideOutput=0 +OverrideOutputName= +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings= + +[Unit1] +FileName=yaffut.h +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=test.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=test_args.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=test_class_args.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=test_class_mock.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=test_except.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=test_functors.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=test_optional.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit9] +FileName=test_retval.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit10] +FileName=yaffut.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit11] +FileName=test_ref_args.cpp +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit12] +FileName=hippomocks.h +CompileCpp=1 +Folder=HippoMocks +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.pro b/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.pro new file mode 100644 index 0000000..e355ac2 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocks.pro @@ -0,0 +1,46 @@ +QT += core + +TARGET = Hippomocks +CONFIG += console static +CONFIG -= app_bundle + +TEMPLATE = app + +INCLUDEPATH += ../Hippomocks + +# Uncomment to enable test coverage data: +#QMAKE_CXXFLAGS += -g -O0 -fprofile-arcs -ftest-coverage +#QMAKE_LFLAGS += -g -O0 -fprofile-arcs -ftest-coverage + + +HEADERS += Framework.h + +SOURCES += \ + Framework.cpp \ + is_virtual.cpp \ + main.cpp \ + test.cpp \ + test_args.cpp \ + test_array.cpp \ + test_autoptr.cpp \ + test_cfuncs.cpp \ + test_class_args.cpp \ + test_constref_params.cpp \ + test_cv_funcs.cpp \ + test_do.cpp \ + test_dontcare.cpp \ + test_except.cpp \ + test_exception_quality.cpp \ + test_filter.cpp \ + test_inparam.cpp \ + test_membermock.cpp \ + test_mi.cpp \ + test_nevercall.cpp \ + test_optional.cpp \ + test_outparam.cpp \ + test_overload.cpp \ + test_ref_args.cpp \ + test_regression_arg_count.cpp \ + test_retval.cpp \ + test_transaction.cpp \ + test_zombie.cpp diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.sln b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.sln new file mode 100644 index 0000000..d6a29e5 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HippoMocksTest", "..\HippoMocksTest\HippoMocksTest.vcproj", "{231F5EB2-1F1D-4C41-9FC1-59118049524F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|x64.ActiveCfg = Debug|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|x64.Build.0 = Debug|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|x64.ActiveCfg = Release|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|x64.Build.0 = Release|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|Win32.ActiveCfg = Debug|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|Win32.Build.0 = Debug|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|Win32.ActiveCfg = Release|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.vcproj b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.vcproj new file mode 100644 index 0000000..97d52f2 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest.vcproj @@ -0,0 +1,443 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.sln b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.sln new file mode 100644 index 0000000..8a1c13f --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HippoMocksTest", "HippoMocksTest_2012.vcxproj", "{231F5EB2-1F1D-4C41-9FC1-59118049524F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|Win32.ActiveCfg = Debug|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|Win32.Build.0 = Debug|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|x64.ActiveCfg = Debug|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Debug|x64.Build.0 = Debug|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|Win32.ActiveCfg = Release|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|Win32.Build.0 = Release|Win32 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|x64.ActiveCfg = Release|x64 + {231F5EB2-1F1D-4C41-9FC1-59118049524F}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.vcxproj b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.vcxproj new file mode 100644 index 0000000..8950ede --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/HippoMocksTest_2012.vcxproj @@ -0,0 +1,199 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {231F5EB2-1F1D-4C41-9FC1-59118049524F} + HippoMocksTest + + + + Application + v110 + MultiByte + true + + + Application + v110 + MultiByte + + + Application + v110 + MultiByte + true + + + Application + v110 + MultiByte + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.50727.1 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + + + + /vmg %(AdditionalOptions) + Disabled + ../HippoMocks/;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + StreamingSIMDExtensions2 + Level4 + EditAndContinue + + + true + MachineX86 + + + $(TargetDir)$(TargetFileName) + + + + + /vmg %(AdditionalOptions) + MaxSpeed + true + ../hippo mocks;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level4 + ProgramDatabase + + + true + true + true + MachineX86 + + + + + /vmg %(AdditionalOptions) + Disabled + ../HippoMocks/;%(AdditionalIncludeDirectories) + true + EnableFastChecks + MultiThreadedDebugDLL + NotSet + Level4 + ProgramDatabase + _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS + + + true + MachineX64 + + + $(TargetDir)$(TargetFileName) + + + + + /vmg %(AdditionalOptions) + MaxSpeed + true + ../hippo mocks;%(AdditionalIncludeDirectories) + MultiThreadedDLL + true + Level4 + ProgramDatabase + + + true + true + true + MachineX86 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/extlibs/hippomocks-master/HippoMocksTest/is_virtual.cpp b/extlibs/hippomocks-master/HippoMocksTest/is_virtual.cpp new file mode 100644 index 0000000..5632530 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/is_virtual.cpp @@ -0,0 +1,65 @@ +#include "Framework.h" +#include +#include "hippomocks.h" + +class IL { +public: + void f() { std::cout << "0" << std::endl; } + virtual void g() { std::cout << "1" << std::endl; } + virtual void h() { std::cout << "2" << std::endl; } +}; + +class SecondBase +{ +public: + virtual void k() { std::cout << "3" << std::endl; } + int x; +}; + +class ThirdBase +{ +public: + virtual void l() { std::cout << "4" << std::endl; } + virtual void m() { std::cout << "4" << std::endl; } +}; + +class ILD : public IL, public SecondBase, public ThirdBase +{ +}; + +TEST(checkNonVirtual) +{ + EQUALS(HippoMocks::virtual_index(&ILD::f).first, -1); +} + +TEST(checkFirstVirtual) +{ + EQUALS(HippoMocks::virtual_index(&ILD::g).first, 0); + EQUALS(HippoMocks::virtual_index(&ILD::g).second, 0); +} + +TEST(checkSecondVirtual) +{ + EQUALS(HippoMocks::virtual_index(&ILD::h).first, 0); + EQUALS(HippoMocks::virtual_index(&ILD::h).second, 1); +} + +TEST(checkSecondBaseFirstVirtual) +{ + EQUALS(HippoMocks::virtual_index((void (ILD::*)())&ILD::k).first, 1); + EQUALS(HippoMocks::virtual_index((void (ILD::*)())&ILD::k).second, 0); +} + +TEST(checkThirdBaseSecondVirtualAfterInt) +{ + EQUALS(HippoMocks::virtual_index((void (ILD::*)())&ILD::m).first, 3); + EQUALS(HippoMocks::virtual_index((void (ILD::*)())&ILD::m).second, 1); +} + +TEST(checkPointerConversionIsOk) +{ + void (ThirdBase::*f)() = &ThirdBase::m; + EQUALS(HippoMocks::virtual_index((void (ILD::*)())f).first, 3); + EQUALS(HippoMocks::virtual_index((void (ILD::*)())f).second, 1); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/main.cpp b/extlibs/hippomocks-master/HippoMocksTest/main.cpp new file mode 100644 index 0000000..d0f4516 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/main.cpp @@ -0,0 +1,8 @@ +#include "Framework.h" + +int main(int , char **) { + return TestRegistry::Instance().RunTests(); +} + + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/makefile b/extlibs/hippomocks-master/HippoMocksTest/makefile new file mode 100644 index 0000000..2a0d46e --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/makefile @@ -0,0 +1,25 @@ +CXX?=g++ +STDVER?=c++98 +WARNFLAGS = -Wall -Wextra -pedantic -Wno-long-long +CXXOPTS = -I../HippoMocks/ $(WARNFLAGS) -g +TARGET = $(PREFIX)test.exe + +OBJECTS = $(patsubst %,$(PREFIX)%,is_virtual.o test.o test_args.o test_array.o test_autoptr.o test_cfuncs.o test_class_args.o test_constref_params.o test_cv_funcs.o test_do.o test_dontcare.o test_except.o test_exception_quality.o test_filter.o test_inparam.o test_membermock.o test_mi.o test_nevercall.o test_optional.o test_outparam.o test_overload.o test_ref_args.o test_regression_arg_count.o test_retval.o test_transaction.o test_zombie.o Framework.o main.o) + +all: $(TARGETS) + +clean: + $(RM) $(OBJECTS) $(TARGETS) $(OBJECTS:%.o=%.d) + +runtest: $(TARGET) + ./$(TARGET) + +%.o: %.cpp makefile + $(CXX) $(CFLAGS) $(CXXOPTS) -std=$(STDVER) -c -o $@ $< -MMD -MP + +$(TARGET): $(OBJECTS) + $(CXX) $(CFLAGS) $(CXXOPTS) -std=$(STDVER) -o $@ $^ + +-include $(OBJECTS:%.o=%.d) + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test.cpp b/extlibs/hippomocks-master/HippoMocksTest/test.cpp new file mode 100644 index 0000000..55ffed7 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test.cpp @@ -0,0 +1,124 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IA { +public: + virtual ~IA() {} + virtual void f() {} + virtual void g() = 0; +}; + +TEST (checkBaseCase) +{ + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + iamock->f(); + iamock->g(); +} + +TEST (checkMultiCall) +{ + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + mocks.ExpectCall(iamock, IA::f); + iamock->f(); + iamock->g(); + iamock->f(); +} + +TEST (checkMultiCallNotCalled) +{ + bool exceptionCaught = false; + try { + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + mocks.ExpectCall(iamock, IA::f); + iamock->f(); + iamock->g(); + } + catch (HippoMocks::CallMissingException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +TEST (checkMultiCallWrongOrder) +{ + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + mocks.ExpectCall(iamock, IA::f); + iamock->f(); + bool exceptionCaught = false; + try { + iamock->f(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + mocks.reset(); +} + +TEST (checkExpectationsNotCompleted) +{ + bool exceptionCaught = false; + try { + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + iamock->f(); + } + catch (HippoMocks::CallMissingException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +TEST (checkOvercompleteExpectations) +{ + bool exceptionCaught = false; + try { + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + iamock->f(); + iamock->g(); + iamock->f(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +TEST (checkExpectationsAreInOrder) +{ + bool exceptionCaught = false; + try { + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IA::f); + mocks.ExpectCall(iamock, IA::g); + iamock->g(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_args.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_args.cpp new file mode 100644 index 0000000..4e473ac --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_args.cpp @@ -0,0 +1,39 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IB { +public: + virtual ~IB() {} + virtual void f(int); + virtual void g(int) = 0; +}; + +TEST (checkArgumentsAccepted) +{ + MockRepository mocks; + IB *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IB::f).With(1); + mocks.ExpectCall(iamock, IB::g).With(2); + iamock->f(1); + iamock->g(2); +} + +TEST (checkArgumentsChecked) +{ + MockRepository mocks; + IB *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IB::f).With(1); + mocks.ExpectCall(iamock, IB::g).With(1); + bool exceptionCaught = false; + try + { + iamock->f(2); + } + catch (HippoMocks::ExpectationException) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + mocks.reset(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_array.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_array.cpp new file mode 100644 index 0000000..141dbcf --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_array.cpp @@ -0,0 +1,21 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IArrayArgs { +public: + virtual ~IArrayArgs() {} + virtual void f(std::string); + virtual void g(std::wstring) = 0; +}; + +TEST (checkArrayArgumentsAccepted) +{ + MockRepository mocks; + IArrayArgs *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IArrayArgs::f).With("Hello"); + mocks.ExpectCall(iamock, IArrayArgs::g).With(L"World"); + iamock->f("Hello"); + iamock->g(L"World"); +} + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_autoptr.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_autoptr.cpp new file mode 100644 index 0000000..0ebd178 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_autoptr.cpp @@ -0,0 +1,69 @@ +#include "hippomocks.h" +#include "Framework.h" +#include +using std::auto_ptr; + +class X {}; + +class IQ { +public: + virtual ~IQ() {} + virtual void f(); + virtual auto_ptr g(); + virtual auto_ptr getSelf(); +}; + +TEST (checkAutoptrReturnable) +{ + X *_t = new X; + + MockRepository mocks; + IQ *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IQ::g).Return(auto_ptr(_t)); + CHECK(_t == iamock->g().get()); +} + +TEST (checkAutoptrCanReturnMock) +{ + MockRepository mocks; + IQ *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IQ::getSelf).Return(auto_ptr(iamock)); + mocks.ExpectCallDestructor(iamock); + CHECK(iamock == iamock->getSelf().get()); +} + +TEST(checkCanDestroyMock) +{ + MockRepository mocks; + IQ *iamock = mocks.Mock(); + mocks.ExpectCallDestructor(iamock); + delete iamock; +} + +TEST(checkAutoptrStability) +{ + int exceptionsCaught = 0; + try + { + MockRepository mocks; + try + { + IQ *iamock = mocks.Mock(); + auto_ptr auto_ptr(iamock); + mocks.ExpectCall(iamock, IQ::f); + mocks.ExpectCallDestructor(iamock); + throw 42; + // implicit: destructor for iamock, that may not throw + } + catch(int) + { + exceptionsCaught++; + } + } + catch(HippoMocks::ExpectationException) + { + exceptionsCaught++; + } + CHECK(exceptionsCaught == 2); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_cfuncs.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_cfuncs.cpp new file mode 100644 index 0000000..d472037 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_cfuncs.cpp @@ -0,0 +1,45 @@ +#include "hippomocks.h" +#include "Framework.h" + +// If it's not supported, then don't test it. +#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT +int a() +{ + return 1; +} + +TEST (checkFunctionReplacedAndChecked) +{ + EQUALS(a(), 1); + MockRepository mocks; + mocks.ExpectCallFunc(a).Return(2); + EQUALS(a(), 2); +} + +TEST (checkFunctionReturnedToOriginal) +{ + { + EQUALS(a(), 1); + MockRepository mocks; + mocks.ExpectCallFunc(a).Return(2); + EQUALS(a(), 2); + } + EQUALS(a(), 1); +} + +#ifdef _WIN32 +#include +TEST (checkCanMockGetSystemTime) { + MockRepository mocks; + SYSTEMTIME outtime; + outtime.wDay = 1; + SYSTEMTIME systime; + systime.wDay = 0; + mocks.ExpectCallFunc(GetSystemTime).With(Out(outtime)); + GetSystemTime(&systime); + EQUALS(systime.wDay, 1); +} +#endif + +#endif + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_class_args.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_class_args.cpp new file mode 100644 index 0000000..22dac9c --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_class_args.cpp @@ -0,0 +1,49 @@ +#include "hippomocks.h" +#include "Framework.h" +#include + +// non-reference is bad, but should work +class IC { +public: + virtual ~IC() {} + virtual void f(std::string s); + virtual void g(std::string s) = 0; +}; + +TEST (checkClassArgumentsAccepted) +{ + MockRepository mocks; + IC *iamock = mocks.Mock(); + mocks.OnCall(iamock, IC::f).With("hi"); + mocks.OnCall(iamock, IC::g).With("bye"); + iamock->f("hi"); + iamock->g("bye"); +} + +TEST (checkClassArgumentsChecked) +{ + MockRepository mocks; + IC *iamock = mocks.Mock(); + mocks.OnCall(iamock, IC::f).With("hi"); + mocks.OnCall(iamock, IC::g).With("bye"); + bool exceptionCaught = false; + try + { + iamock->f("bye"); + } + catch (HippoMocks::ExpectationException) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + mocks.reset(); +} + +TEST (checkClassArgumentsIgnored) +{ + MockRepository mocks; + IC *iamock = mocks.Mock(); + mocks.OnCall(iamock, IC::f); + iamock->f("bye"); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_com_support_stdcall.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_com_support_stdcall.cpp new file mode 100644 index 0000000..821eac4 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_com_support_stdcall.cpp @@ -0,0 +1,256 @@ +#include "Framework.h" +#include + +#ifdef _MSC_VER + +#include +#include +#include + + +namespace ComSupportTests +{ + +class ICom +{ +public: + virtual ~ICom() {} + virtual long __stdcall A(void) = 0; + virtual long __stdcall B(int) = 0; + virtual long __stdcall C(int, int) = 0; + virtual long __stdcall D(int, int, int) = 0; + virtual long __stdcall E(int, int, int, int) = 0; + virtual long __stdcall F(int, int, int, int, int) = 0; + virtual long __stdcall G(int, int, int, int, int, int) = 0; + virtual long __stdcall H(int, int, int, int, int, int, int) = 0; + virtual long __stdcall I(int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall J(int, int, int, int, int, int, int, int, int ) = 0; + virtual long __stdcall K(int, int, int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall L(int, int, int, int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall M(int, int, int, int, int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall N(int, int, int, int, int, int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall O(int, int, int, int, int, int, int, int, int, int, int, int, int, int) = 0; + virtual long __stdcall P(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) = 0; +}; + + +TEST(checkStdCallBase) +{ + MockRepository mocks; + + ICom* ic = mocks.Mock(); + mocks.ExpectCall(ic, ICom::A) + .Return(1); + + long actual = ic->A(); + EQUALS(1, actual); +} + +TEST(checkStdCallTemplateWithArgumentsImplementations) +{ + MockRepository mocks; + + ICom* ic = mocks.Mock(); + + mocks.ExpectCall(ic, ICom::B) + .Return(2); + mocks.ExpectCall(ic, ICom::C) + .Return(3); + mocks.ExpectCall(ic, ICom::D) + .Return(4); + mocks.ExpectCall(ic, ICom::E) + .Return(5); + mocks.ExpectCall(ic, ICom::F) + .Return(6); + mocks.ExpectCall(ic, ICom::G) + .Return(7); + mocks.ExpectCall(ic, ICom::H) + .Return(8); + mocks.ExpectCall(ic, ICom::I) + .Return(9); + mocks.ExpectCall(ic, ICom::J) + .Return(10); + mocks.ExpectCall(ic, ICom::K) + .Return(11); + mocks.ExpectCall(ic, ICom::L) + .Return(12); + mocks.ExpectCall(ic, ICom::M) + .Return(13); + mocks.ExpectCall(ic, ICom::N) + .Return(14); + mocks.ExpectCall(ic, ICom::O) + .Return(15); + mocks.ExpectCall(ic, ICom::P) + .Return(16); + + ic->B(1); + ic->C(1,2); + ic->D(1,2,3); + ic->E(1,2,3,4); + ic->F(1,2,3,4,5); + ic->G(1,2,3,4,5,6); + ic->H(1,2,3,4,5,6,7); + ic->I(1,2,3,4,5,6,7,8); + ic->J(1,2,3,4,5,6,7,8,9); + ic->K(1,2,3,4,5,6,7,8,9,10); + ic->L(1,2,3,4,5,6,7,8,9,10,11); + ic->M(1,2,3,4,5,6,7,8,9,10,11,12); + ic->N(1,2,3,4,5,6,7,8,9,10,11,12,13); + ic->O(1,2,3,4,5,6,7,8,9,10,11,12,13,14); + ic->P(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); +} + +TEST(checkUnexpectedMethodCallThrowsException) +{ + //MockRepository mocks; + + //ICom* ic = mocks.Mock(); + + //ic->A(); +} + + +template +int virtual_function_index(unsigned char* pb) +{ + if (*pb == 0xE9) + { + return virtual_function_index<0>(pb + 5 + *(unsigned int *)(pb+1)); + } + if (!pb) return -1; + int pboff = -1; + if (pb[0] == 0x8b && pb[1] == 0x01) + { //mov eax, [ecx] + pboff = 2; + } + else if (pb[0] == 0x8b && pb[1] == 0x44 && pb[2] == 0x24 && pb[3] == 0x04 && //mov eax, [esp+arg0] + pb[4] == 0x8b && pb[5] == 0x00) //mov eax, [eax] + { + pboff = 6; + } + + if (pboff > 0) + { + if (pb[pboff] == 0xff) + { + switch (pb[pboff + 1]) + { + case 0x20: //jmp dword ptr [eax] + return 0; + case 0x60: //jmp dword ptr [eax+0xNN] + return (((int)pb[pboff + 2]) & 0xff) / 4; + case 0xa0: //jmp dword ptr [eax+0xNNN] + return (*(unsigned int*)(pb + (pboff + 2))) / 4; + default: + break; + } + } + } + return -1; +} + +template +int VirtualFIndex(T func) +{ + union { + T pfn; + unsigned char* pb; + }; + pfn = func; + return virtual_function_index<0>(pb); +} + +struct AA +{ + virtual int Get1() = 0; + virtual int Get2() {} +}; + +//class with only 1 virtual method +class IAA { +public: + virtual int f(int a); +}; + + +MIDL_INTERFACE("4745C05E-23E6-4c6d-B9F2-E483359A8B89") +COMInterface1 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE getTObjectCount( + /* [out] */ unsigned long *pCount) = 0; +}; + +typedef GUID ESTypeID; + +MIDL_INTERFACE("356D44D9-980A-4149-A586-C5CB8B191437") +COMInterface2 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE getMappablePackages( + /* [out] */ long *pSize, + /* [size_is][size_is][out] */ ESTypeID **pIdList) = 0; +}; +#if 0 +TEST(EnsureThat_VirtualFunctionIndexGenericWorksforAllCases) +{ + EQUALS(1, VirtualFIndex(&AA::Get2)); + EQUALS(0, VirtualFIndex(&AA::Get1)); + EQUALS(0, VirtualFIndex(&IAA::f)); + + EQUALS(0, VirtualFIndex(&IUnknown::QueryInterface)); + EQUALS(1, VirtualFIndex(&IUnknown::AddRef)); + EQUALS(2, VirtualFIndex(&IUnknown::Release)); + + EQUALS(0, VirtualFIndex(&COMInterface1::QueryInterface)); + EQUALS(1, VirtualFIndex(&COMInterface1::AddRef)); + EQUALS(2, VirtualFIndex(&COMInterface1::Release)); +} +#endif + +TEST(CheckThat_AddCommExpectations_Stubs_QueryInterface_AddRef_Release) +{ + MockRepository mocks; + COMInterface1* deviceMock = mocks.Mock(); + + AddComExpectations(mocks, deviceMock); + + { + CComPtr pUnk = deviceMock; + CComQIPtr pDevice = pUnk; + + CHECK(pDevice == pUnk); + + IUnknown* p = NULL; + pDevice->QueryInterface(__uuidof(IUnknown), (void**)&p); + + CHECK(p == deviceMock); + + } +} + +TEST(CheckThat_ConnectComInterfaces_Stubs_QueryInterface_ToEachOther) +{ + MockRepository mocks; + COMInterface1* deviceMock = mocks.Mock(); + COMInterface2* devMappingMock = mocks.Mock(); + + ConnectComInterfaces(mocks, deviceMock, devMappingMock); + + { + //Com objects can reach each other + CComQIPtr pDevMapping = deviceMock; + + CHECK(pDevMapping != NULL); + CHECK(pDevMapping == devMappingMock); + + CComQIPtr pDevNavigate = devMappingMock; + + CHECK(pDevNavigate != NULL); + CHECK(pDevNavigate == deviceMock); + } + +} +} // end of namespace + +#endif diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_constref_params.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_constref_params.cpp new file mode 100644 index 0000000..6e2eeb8 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_constref_params.cpp @@ -0,0 +1,54 @@ +#include "hippomocks.h" +#include "Framework.h" +#include + +using HippoMocks::byRef; + +class IR { +public: + virtual void func() = 0; +}; + +class R : public IR { +public: + virtual void func() {} +}; + +class IM { +public: + virtual ~IM() {} + virtual void d(std::string var) = 0; + virtual void e(const std::string &var) = 0; + virtual void f(const IR &arg) = 0; +}; + +TEST (checkTemporaryClassParam) +{ + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IM::d).With("Hello"); + iamock->d("Hello"); +} + +TEST (checkConstRefClassParam) +{ + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IM::e).With("Hello"); + iamock->e("Hello"); +} + +bool operator==(const IR &objA, const IR &objB) +{ + return &objA == &objB; +} + +TEST (checkConstRefAbstractClassParam) +{ + R r; + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IM::f).With(byRef(r)); + iamock->f(r); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_cv_funcs.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_cv_funcs.cpp new file mode 100644 index 0000000..ea43bd0 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_cv_funcs.cpp @@ -0,0 +1,26 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IM { +public: + virtual ~IM() {} + virtual void e() = 0; + virtual void f() const = 0; + virtual void g() volatile = 0; + virtual void h() const volatile = 0; +}; + +TEST (checkCVQualifiedMemberFunctions) +{ + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IM::e); + mocks.ExpectCall(iamock, IM::f); + mocks.ExpectCall(iamock, IM::g); + mocks.ExpectCall(iamock, IM::h); + iamock->e(); + iamock->f(); + iamock->g(); + iamock->h(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_do.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_do.cpp new file mode 100644 index 0000000..3d35ab9 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_do.cpp @@ -0,0 +1,104 @@ +#include +#include "hippomocks.h" +#include "Framework.h" + +using HippoMocks::byRef; + +class IDoFunctor { +public: + virtual ~IDoFunctor() {} + virtual void a(std::string arg) = 0; +}; + +#if __cplusplus > 199711L +TEST (checkDoFunctorCanBeLambdaWithContent) +{ + MockRepository mocks; + IDoFunctor *iamock = mocks.Mock(); + { + std::string value = "Hello World"; + mocks.ExpectCall(iamock, IDoFunctor::a).Do([=](std::string arg){ + CHECK(arg == value); + }); + } + + iamock->a("Hello World"); +} +#endif + +class II { +public: + virtual ~II() {} + virtual void f() {} + virtual void g() = 0; +}; + +bool checked; +void setChecked() { checked = true; } + +class functorClass { +public: + functorClass() : calls(0) {} + int calls; + void operator()() { ++calls; } +}; + +TEST (checkFunctorsCalled) +{ + MockRepository mocks; + II *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, II::f).Do(setChecked); + mocks.OnCall(iamock, II::g).Do(setChecked); + checked = false; + iamock->g(); + CHECK(checked == true); + checked = false; + iamock->f(); + CHECK(checked == true); + checked = false; + iamock->g(); + CHECK(checked == true); +} + +TEST (checkFunctorObjectCalled) +{ + MockRepository mocks; + II *iamock = mocks.Mock(); + functorClass obj; + mocks.ExpectCall(iamock, II::f).Do(byRef(obj)); + mocks.OnCall(iamock, II::g).Do(byRef(obj)); + CHECK(obj.calls == 0); + iamock->g(); + CHECK(obj.calls == 1); + iamock->f(); + CHECK(obj.calls == 2); + iamock->g(); + CHECK(obj.calls == 3); +} + +class functorByVal { +public: + functorByVal(int &count) : count(count) {} + void operator()() { count++; } + int &count; +private: + functorByVal &operator=(const functorByVal&); // Silence VS +}; + +TEST (checkFunctorObjectByvalCalled) +{ + int count = 0; + MockRepository mocks; + II *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, II::f).Do(functorByVal(count)); + mocks.OnCall(iamock, II::g).Do(functorByVal(count)); + CHECK(count == 0); + iamock->g(); + CHECK(count == 1); + iamock->f(); + CHECK(count == 2); + iamock->g(); + CHECK(count == 3); +} + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_dontcare.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_dontcare.cpp new file mode 100644 index 0000000..82065af --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_dontcare.cpp @@ -0,0 +1,29 @@ +#include "Framework.h" +#include "hippomocks.h" + +class IZ { +public: + virtual ~IZ() {} +}; + +class IY { +public: + virtual bool test(int a, IZ &b); +}; + +bool operator==(const IZ &, const IZ &) +{ + return false; +} + +TEST (checkDontcareIsIgnored) +{ + MockRepository mocks; + IY *iamock = mocks.Mock(); + mocks.OnCall(iamock, IY::test).Return(false); + mocks.OnCall(iamock, IY::test).With(42, _).Return(true); + IZ iz; + EQUALS(true, iamock->test(42, iz)); + EQUALS(false, iamock->test(40, iz)); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_except.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_except.cpp new file mode 100644 index 0000000..7644174 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_except.cpp @@ -0,0 +1,87 @@ +#include "hippomocks.h" +#include "Framework.h" + +// For obvious reasons, the Throw is not present when you disable exceptions. +#ifndef HM_NO_EXCEPTIONS +class IE { +public: + virtual ~IE() {} + virtual int f(); + virtual std::string g() = 0; +}; + +TEST (checkPrimitiveExceptionAcceptedAndThrown) +{ + MockRepository mocks; + IE *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IE::f).Throw(42); + bool exceptionCaught = false; + try + { + iamock->f(); + } + catch(int a) + { + CHECK(a == 42); + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +class SomeException : public std::exception { +private: + const char *text; +public: + SomeException(const char *txt) : text(txt) {} + const char *what() const throw() { return text; } +}; + +TEST (checkClassTypeExceptionWithContent) +{ + const char *sText = "someText"; + MockRepository mocks; + IE *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IE::f).Throw(SomeException(sText)); + bool exceptionCaught = false; + try + { + iamock->f(); + } + catch(SomeException &a) + { + CHECK(a.what() == sText); + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +TEST(checkMockRepoVerifyDoesNotThrowDuringException) +{ + bool exceptionCaught = false; + try + { + MockRepository mocks; + IE *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IE::f); + } + catch (HippoMocks::CallMissingException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + exceptionCaught = false; + try + { + MockRepository mocks; + IE *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IE::f); + throw 42; + } + catch (int) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} +#endif + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_exception_quality.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_exception_quality.cpp new file mode 100644 index 0000000..b7627fc --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_exception_quality.cpp @@ -0,0 +1,182 @@ +#include "Framework.h" +#include "hippomocks.h" +#include + +struct X {}; + +bool operator==(const X &, const X &) +{ + return true; +} + +class IS { +public: + virtual ~IS() {} + virtual int f() { return 1; } + virtual int g(int, int) { return 2; } + virtual void h() = 0; + virtual void i(int, const X &) = 0; +}; + +TEST (checkNoResultContainsFuncName) +{ + bool exceptionCaught = false; + MockRepository mocks; + IS *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IS::f); + try { + iamock->f(); + } catch(HippoMocks::NoResultSetUpException &ex) { + exceptionCaught = true; + CHECK(strstr(ex.what(), "IS::f") != NULL); + } + CHECK(exceptionCaught); +} + +TEST (checkNoResultContainsBlankArgSpec) +{ + bool exceptionCaught = false; + MockRepository mocks; + IS *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IS::g); + try { + iamock->g(1,2); + } catch(HippoMocks::NoResultSetUpException &ex) { + exceptionCaught = true; + CHECK(strstr(ex.what(), "IS::g") != NULL); + CHECK(strstr(ex.what(), "(...)") != NULL); + } + CHECK(exceptionCaught); +} + +TEST (checkNoResultContainsActualArgSpec) +{ + bool exceptionCaught = false; + MockRepository mocks; + IS *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IS::g).With(1,2); + try { + iamock->g(1,2); + } catch(HippoMocks::NoResultSetUpException &ex) { + exceptionCaught = true; + CHECK(strstr(ex.what(), "IS::g") != NULL); + CHECK(strstr(ex.what(), "(1,2)") != NULL); + } + CHECK(exceptionCaught); +} + +TEST (checkNoResultContainsActualUnprintableArgSpec) +{ + bool exceptionCaught = false; + MockRepository mocks; + IS *iamock = mocks.Mock(); + mocks.NeverCall(iamock, IS::i).With(42, X()); + try { + iamock->h(); + } catch(HippoMocks::NotImplementedException &ex) { + exceptionCaught = true; + CHECK(strstr(ex.what(), "IS::i") != NULL); + CHECK(strstr(ex.what(), "(42,??\?)") != NULL); + } + CHECK(exceptionCaught); +} + +TEST (checkNoResultDoesNotComplainIfNotCalled) +{ + MockRepository mocks; + IS *iamock = mocks.Mock(); + mocks.OnCall(iamock, IS::g).With(1,2); + mocks.OnCall(iamock, IS::g).With(3,4).Return(42); + iamock->g(3,4); +} + +TEST(checkNotImplementedExceptionToContainInfo) +{ + bool exceptionCaught = false; + MockRepository mocks; + mocks.autoExpect = false; + IS *ismock = mocks.Mock(); + mocks.ExpectCall(ismock, IS::f).Return(1); + mocks.OnCall(ismock, IS::f).Return(2); + mocks.ExpectCall(ismock, IS::g).With(1,2).Return(2); + mocks.OnCall(ismock, IS::g).Return(3); + mocks.NeverCall(ismock, IS::g).With(3,4); + + try + { + ismock->h(); + } + catch (HippoMocks::NotImplementedException &ex) + { + CHECK(strstr(ex.what(), "Expectation for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Expectation for IS::g(1,2)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(...)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(3,4)") != NULL); + CHECK(strstr(ex.what(), __FILE__) != NULL); + exceptionCaught = true; + } + mocks.reset(); + CHECK(exceptionCaught); +} + +TEST(checkExpectationExceptionToContainInfo) +{ + bool exceptionCaught = false; + MockRepository mocks; + mocks.autoExpect = false; + IS *ismock = mocks.Mock(); + mocks.ExpectCall(ismock, IS::f).Return(1); + mocks.OnCall(ismock, IS::f).Return(2); + mocks.ExpectCall(ismock, IS::g).With(1,2).Return(2); + mocks.OnCall(ismock, IS::g).With(2,3).Return(3); + mocks.NeverCall(ismock, IS::g).With(3,4); + mocks.NeverCall(ismock, IS::h); + + try + { + ismock->g(0,1); + } + catch (HippoMocks::ExpectationException &ex) + { + CHECK(strstr(ex.what(), "Function IS::g(0,1) called") != NULL); + CHECK(strstr(ex.what(), "Expectation for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Expectation for IS::g(1,2)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(2,3)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(3,4)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::h()") != NULL); + CHECK(strstr(ex.what(), __FILE__) != NULL); + exceptionCaught = true; + } + mocks.reset(); + CHECK(exceptionCaught); +} + +TEST(checkCallMissingExceptionToContainInfo) +{ + bool exceptionCaught = false; + try + { + MockRepository mocks; + mocks.autoExpect = false; + IS *ismock = mocks.Mock(); + mocks.ExpectCall(ismock, IS::f).Return(1); + mocks.OnCall(ismock, IS::f).Return(2); + mocks.ExpectCall(ismock, IS::g).With(1,2).Return(2); + mocks.OnCall(ismock, IS::g).Return(3); + mocks.NeverCall(ismock, IS::g).With(3,4); + } + catch (HippoMocks::CallMissingException &ex) + { + CHECK(strstr(ex.what(), "Expectation for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::f()") != NULL); + CHECK(strstr(ex.what(), "Expectation for IS::g(1,2)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(...)") != NULL); + CHECK(strstr(ex.what(), "Result set for IS::g(3,4)") != NULL); + CHECK(strstr(ex.what(), __FILE__) != NULL); + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_filter.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_filter.cpp new file mode 100644 index 0000000..84ccc58 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_filter.cpp @@ -0,0 +1,32 @@ +#include "Framework.h" +#include "hippomocks.h" + +class IAA { +public: + virtual int f(int a, int b, int c); +}; + +bool allEven(int a, int b, int c) { return (a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0); } +bool oeo(int a, int b, int c) { return (a % 2 == 1) && (b % 2 == 0) && (c % 2 == 1); } +bool eod(int a, int b, int) { return (a % 2 == 0) && (b % 2 == 1); } +bool never(int, int, int) { return false; } + +TEST (checkFilterIsApplied) +{ + MockRepository mocks; + IAA *iamock = mocks.Mock(); + mocks.OnCall(iamock, IAA::f).Return(4); + mocks.OnCall(iamock, IAA::f).Match(never).Return(3); + mocks.OnCall(iamock, IAA::f).Match(eod).Return(2); + mocks.OnCall(iamock, IAA::f).Match(oeo).Return(1); + mocks.OnCall(iamock, IAA::f).Match(allEven).Return(5); + EQUALS(5, iamock->f(0, 0, 0)); + EQUALS(4, iamock->f(0, 0, 1)); + EQUALS(2, iamock->f(0, 1, 0)); + EQUALS(2, iamock->f(0, 1, 1)); + EQUALS(4, iamock->f(1, 0, 0)); + EQUALS(1, iamock->f(1, 0, 1)); + EQUALS(4, iamock->f(1, 1, 0)); + EQUALS(4, iamock->f(1, 1, 1)); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_inparam.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_inparam.cpp new file mode 100644 index 0000000..17f5929 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_inparam.cpp @@ -0,0 +1,62 @@ +#include +#include "hippomocks.h" +#include "Framework.h" + +class IInParam { +public: + virtual ~IInParam() {} + virtual void a(const std::string& in) = 0; + virtual void b(std::string* in) = 0; + virtual void c(const char* in) = 0; +}; + +TEST (checkInParamsAreFilledIn_ConstChar) +{ + MockRepository mocks; + IInParam *iamock = mocks.Mock(); + std::string teststring; + mocks.ExpectCall(iamock, IInParam::a).With(In(teststring)); + + iamock->a("Hello World"); + + CHECK(teststring == "Hello World"); +} + +TEST (checkInParamsAreFilledIn_String) +{ + MockRepository mocks; + IInParam *iamock = mocks.Mock(); + std::string teststring; + mocks.ExpectCall(iamock, IInParam::a).With(In(teststring)); + + std::string in("Hello World"); + iamock->a(in); + + CHECK(teststring == in); +} + +TEST (checkInParamsAreFilledIn_PointerToString) +{ + MockRepository mocks; + IInParam *iamock = mocks.Mock(); + std::string* teststring = NULL; + mocks.ExpectCall(iamock, IInParam::b).With(In(teststring)); + + std::string in("Hello World"); + iamock->b(&in); + + CHECK(teststring == &in); +} + +TEST (checkInParamsAreFilledIn_Char) +{ + MockRepository mocks; + IInParam *iamock = mocks.Mock(); + const char* teststring = NULL; + mocks.ExpectCall(iamock, IInParam::c).With(In(teststring)); + + const char* in = "Hello World"; + iamock->c(in); + + CHECK(strcmp(teststring, in) == 0); +} diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_membermock.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_membermock.cpp new file mode 100644 index 0000000..acba6cf --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_membermock.cpp @@ -0,0 +1,19 @@ +#include "hippomocks.h" +#include "Framework.h" +#include + +class IT { +public: + std::string text; + virtual std::string getText() { return text; } +}; + +TEST (checkMemberWorks) +{ + MockRepository mocks; + IT *iamock = mocks.Mock(); + mocks.Member(iamock, &IT::text); + iamock->text = "helloworld"; + EQUALS("helloworld", iamock->text); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_mi.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_mi.cpp new file mode 100644 index 0000000..f041337 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_mi.cpp @@ -0,0 +1,30 @@ +#include "hippomocks.h" +#include "Framework.h" + +class BaseA { +public: + virtual void a() = 0; +}; + +class BaseB { +public: + virtual void b() = 0; +}; + +class ClassC : public BaseA, public BaseB { +public: + virtual void c() = 0; +}; + +TEST (checkMICallsWork) +{ + MockRepository mocks; + ClassC *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, ClassC::a); + mocks.ExpectCall(iamock, ClassC::c); + mocks.ExpectCall(iamock, ClassC::b); + iamock->a(); + iamock->c(); + iamock->b(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_nevercall.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_nevercall.cpp new file mode 100644 index 0000000..f370af8 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_nevercall.cpp @@ -0,0 +1,81 @@ +#include "Framework.h" +#include "hippomocks.h" + +class IR { +public: + virtual ~IR() {} + virtual void f() {} + virtual void g() {} + virtual int h() { return 0; } +}; + +TEST (checkNeverCallWorks) +{ + bool exceptionCaught = false; + MockRepository mocks; + IR *iamock = mocks.Mock(); + Call &callF = mocks.ExpectCall(iamock, IR::f); + mocks.OnCall(iamock, IR::g); + mocks.NeverCall(iamock, IR::g).After(callF); + iamock->g(); + iamock->g(); + iamock->f(); + try + { + iamock->g(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + +TEST (checkNeverCallExceptionDetail) +{ + bool exceptionCaught = false; + MockRepository mocks; + IR *iamock = mocks.Mock(); + mocks.NeverCall(iamock, IR::g); + try + { + iamock->g(); + } + catch (HippoMocks::ExpectationException &ex) + { + exceptionCaught = true; + CHECK(strstr(ex.what(), "IR::g") != NULL); + } + CHECK(exceptionCaught); +} + +TEST (checkInteractionBetweenCallTypesWorks) +{ + bool exceptionCaught = false; + MockRepository mocks; + mocks.autoExpect = false; + IR *iamock = mocks.Mock(); + Call &callF = mocks.ExpectCall(iamock, IR::f); + Call &onCallG = mocks.OnCall(iamock, IR::g); + mocks.OnCall(iamock, IR::h).Return(2); + Call &returnThree = mocks.ExpectCall(iamock, IR::h).After(onCallG).Return(3); + Call &returnFour = mocks.ExpectCall(iamock, IR::h).After(callF).Return(4); + mocks.NeverCall(iamock, IR::h).After(returnThree).After(returnFour); + CHECK(iamock->h() == 2); + CHECK(iamock->h() == 2); + iamock->f(); + CHECK(iamock->h() == 4); + CHECK(iamock->h() == 2); + iamock->g(); + CHECK(iamock->h() == 3); + try + { + iamock->h(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_optional.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_optional.cpp new file mode 100644 index 0000000..aa651a3 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_optional.cpp @@ -0,0 +1,40 @@ +#include "hippomocks.h" +#include "Framework.h" + +class II { +public: + virtual ~II() {} + virtual void f() {} + virtual void g() = 0; +}; + +TEST (checkBaseCaseOptionalOk) +{ + MockRepository mocks; + II *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, II::f); + mocks.OnCall(iamock, II::g); + iamock->g(); + iamock->f(); +} + +TEST (checkBaseCaseOptionalNotRequired) +{ + MockRepository mocks; + II *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, II::f); + mocks.OnCall(iamock, II::g); + iamock->f(); +} + +TEST (checkBaseCaseOptionalTwiceIsOK) +{ + MockRepository mocks; + II *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, II::f); + mocks.OnCall(iamock, II::g); + iamock->g(); + iamock->f(); + iamock->g(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_outparam.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_outparam.cpp new file mode 100644 index 0000000..21068ee --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_outparam.cpp @@ -0,0 +1,65 @@ +#include +#include "hippomocks.h" +#include "Framework.h" + +class IOutParam { +public: + virtual ~IOutParam() {} + virtual void a(std::string& out) = 0; + virtual void b(std::string** out) = 0; + virtual void c(char** out) = 0; +}; + +TEST (checkOutParamsAreFilledIn_ConstChar) +{ + MockRepository mocks; + IOutParam *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IOutParam::a).With(Out("Hello World")); + + std::string out; + iamock->a(out); + + CHECK(out == "Hello World"); +} + +TEST (checkOutParamsAreFilledIn_String) +{ + MockRepository mocks; + IOutParam *iamock = mocks.Mock(); + std::string teststring("Hello World"); + mocks.ExpectCall(iamock, IOutParam::a).With(Out(teststring)); + + std::string out; + iamock->a(out); + + CHECK(out == teststring); +} + +TEST (checkOutParamsAreFilledIn_PointerToString) +{ + MockRepository mocks; + IOutParam *iamock = mocks.Mock(); + std::string teststring("Hello World"); + std::string *outString = new std::string(teststring); + mocks.ExpectCall(iamock, IOutParam::b).With(Out(outString)); + + std::string* out = 0; + iamock->b(&out); + + CHECK(*out == teststring); + + delete outString; +} + +TEST (checkOutParamsAreFilledIn_Char) +{ + MockRepository mocks; + IOutParam *iamock = mocks.Mock(); + const char* teststring = "Hello World"; + mocks.ExpectCall(iamock, IOutParam::c).With(Out((char*)teststring)); + + char* out = 0; + iamock->c(&out); + + CHECK(strcmp(out, teststring) == 0); +} diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_overload.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_overload.cpp new file mode 100644 index 0000000..a085082 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_overload.cpp @@ -0,0 +1,20 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IA { +public: + virtual ~IA() {} + virtual void f() = 0; + virtual void f(int) = 0; +}; + +typedef void (IA::*mf)(); + +TEST (checkOverloadWithCastWorks) +{ + MockRepository mocks; + IA *iamock = mocks.Mock(); + mocks.ExpectCallOverload(iamock, (mf)&IA::f); + iamock->f(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_ref_args.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_ref_args.cpp new file mode 100644 index 0000000..297668e --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_ref_args.cpp @@ -0,0 +1,135 @@ +#include "hippomocks.h" +#include "Framework.h" + +using HippoMocks::byRef; + +class IRefArg { +public: + virtual void test() = 0; +}; + +class IK { +public: + virtual ~IK() {} + virtual void f(int &); + virtual void g(int &) = 0; + virtual int &h() = 0; + virtual const std::string &k() = 0; + virtual void l(IRefArg &refArg) { refArg.test();} +}; + +TEST (checkRefArgumentsAccepted) +{ + MockRepository mocks; + IK *iamock = mocks.Mock(); + int x = 42; + mocks.ExpectCall(iamock, IK::f).With(x); + mocks.ExpectCall(iamock, IK::g).With(x); + iamock->f(x); + iamock->g(x); +} + + +TEST (checkRefArgumentsChecked) +{ + MockRepository mocks; + IK *iamock = mocks.Mock(); + int x = 1, y = 2; + mocks.ExpectCall(iamock, IK::f).With(x); + mocks.ExpectCall(iamock, IK::g).With(y); + bool exceptionCaught = false; + try + { + iamock->f(y); + } + catch (HippoMocks::ExpectationException) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + mocks.reset(); +} + +void plusplus(int &x) +{ + x++; +} +void plusequals2(int &x) +{ + x+=2; +} + +TEST (checkRefArgumentsPassedAsRef) +{ + MockRepository mocks; + IK *iamock = mocks.Mock(); + int x = 1, y = 2; + mocks.ExpectCall(iamock, IK::f).Do(plusplus); + mocks.ExpectCall(iamock, IK::g).Do(plusequals2); + iamock->f(x); + iamock->g(y); + CHECK(x == 2); + CHECK(y == 4); +} + +TEST (checkRefReturnValues) +{ + MockRepository mocks; + IK *iamock = mocks.Mock(); + int x = 0; + mocks.ExpectCall(iamock, IK::h).Return(x); + mocks.ExpectCall(iamock, IK::k).Return("Hello World"); + iamock->h() = 1; + EQUALS(iamock->k(), "Hello World"); + EQUALS(x, 1); +} + +bool operator==(const IRefArg &a, const IRefArg &b) +{ + return (&a == &b); +} + +TEST (checkRefArgCheckedAsReference) +{ + MockRepository mocks; + IK *iamock = mocks.Mock(); + IRefArg *refArg = mocks.Mock(); + + mocks.ExpectCall(iamock, IK::l).With(byRef(*refArg)); + iamock->l(*refArg); +} + +class IB { +public: + virtual ~IB() {} + + virtual void doSomething() const = 0; + +}; + +class IA { +public: + virtual ~IA() {} + + virtual const IB & getB() const = 0; + +}; + +TEST (checkRefReturnAsReference) +{ + MockRepository mocks; + + IB * b = mocks.Mock(); + + IA * a = mocks.Mock(); + + mocks.OnCall(a, IA::getB).ReturnByRef(*b); + mocks.ExpectCall(b, IB::doSomething); + + CHECK(b == &a->getB()); + a->getB().doSomething(); + + mocks.VerifyAll(); +} + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_regression_arg_count.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_regression_arg_count.cpp new file mode 100644 index 0000000..c9373b7 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_regression_arg_count.cpp @@ -0,0 +1,65 @@ +#include "Framework.h" +#include "hippomocks.h" + +class IR { +public: + virtual ~IR() {} + virtual void f0() {} + virtual void f1(int) {} + virtual void f2(int, int) {} + virtual void f3(int, int, int) {} + virtual void f4(int, int, int, int) {} + virtual void f5(int, int, int, int, int) {} + virtual void f6(int, int, int, int, int, int) {} + virtual void f7(int, int, int, int, int, int, int) {} + virtual void f8(int, int, int, int, int, int, int, int) {} + virtual void f9(int, int, int, int, int, int, int, int, int) {} + virtual void f10(int, int, int, int, int, int, int, int, int, int) {} + virtual void f11(int, int, int, int, int, int, int, int, int, int, int) {} + virtual void f12(int, int, int, int, int, int, int, int, int, int, int, int) {} + virtual void f13(int, int, int, int, int, int, int, int, int, int, int, int, int) {} + virtual void f14(int, int, int, int, int, int, int, int, int, int, int, int, int, int) {} + virtual void f15(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) {} + virtual void f16(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) {} +}; + +TEST (checkArgCount16SupportedAndWorking) +{ + MockRepository mocks; + IR *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IR::f0); + mocks.ExpectCall(iamock, IR::f1).With(0); + mocks.ExpectCall(iamock, IR::f2).With(1,2); + mocks.ExpectCall(iamock, IR::f3).With(3,4,5); + mocks.ExpectCall(iamock, IR::f4).With(6,7,8,9); + mocks.ExpectCall(iamock, IR::f5).With(10,11,12,13,14); + mocks.ExpectCall(iamock, IR::f6).With(15,16,17,18,19,20); + mocks.ExpectCall(iamock, IR::f7).With(21,22,23,24,25,26,27); + mocks.ExpectCall(iamock, IR::f8).With(28,29,30,31,32,33,34,35); + mocks.ExpectCall(iamock, IR::f9).With(36,37,38,39,40,41,42,43,44); + mocks.ExpectCall(iamock, IR::f10).With(45,46,47,48,49,50,51,52,53,54); + mocks.ExpectCall(iamock, IR::f11).With(55,56,57,58,59,60,61,62,63,64,65); + mocks.ExpectCall(iamock, IR::f12).With(66,67,68,69,70,71,72,73,74,75,76,77); + mocks.ExpectCall(iamock, IR::f13).With(78,79,80,81,82,83,84,85,86,87,88,89,90); + mocks.ExpectCall(iamock, IR::f14).With(91,92,93,94,95,96,97,98,99,100,101,102,103,104); + mocks.ExpectCall(iamock, IR::f15).With(105,106,107,108,109,110,111,112,113,114,115,116,117,118,119); + mocks.ExpectCall(iamock, IR::f16).With(120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135); + iamock->f0(); + iamock->f1(0); + iamock->f2(1,2); + iamock->f3(3,4,5); + iamock->f4(6,7,8,9); + iamock->f5(10,11,12,13,14); + iamock->f6(15,16,17,18,19,20); + iamock->f7(21,22,23,24,25,26,27); + iamock->f8(28,29,30,31,32,33,34,35); + iamock->f9(36,37,38,39,40,41,42,43,44); + iamock->f10(45,46,47,48,49,50,51,52,53,54); + iamock->f11(55,56,57,58,59,60,61,62,63,64,65); + iamock->f12(66,67,68,69,70,71,72,73,74,75,76,77); + iamock->f13(78,79,80,81,82,83,84,85,86,87,88,89,90); + iamock->f14(91,92,93,94,95,96,97,98,99,100,101,102,103,104); + iamock->f15(105,106,107,108,109,110,111,112,113,114,115,116,117,118,119); + iamock->f16(120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_retval.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_retval.cpp new file mode 100644 index 0000000..5aa4eec --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_retval.cpp @@ -0,0 +1,48 @@ +#include "hippomocks.h" +#include "Framework.h" + +class ID { +public: + virtual ~ID() {} + virtual int f(); + virtual std::string g() = 0; +}; + +TEST (checkRetvalAccepted) +{ + MockRepository mocks; + ID *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, ID::f).Return(1); + mocks.ExpectCall(iamock, ID::g).Return("fsck"); + iamock->f(); + iamock->g(); +} + +TEST (checkRetvalProper) +{ + MockRepository mocks; + ID *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, ID::f).Return(1); + mocks.ExpectCall(iamock, ID::g).Return("fsck"); + CHECK(iamock->f() == 1); + CHECK(iamock->g() == "fsck"); +} + +bool replace_g_called = false; +std::string replace_g() +{ + replace_g_called = true; + return ""; +} + +TEST (checkRetvalAfterDo) +{ + MockRepository mocks; + ID *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, ID::g).Do(replace_g).Return("fsck"); + replace_g_called = false; + CHECK(iamock->g() == "fsck"); + CHECK(replace_g_called); +} + + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_transaction.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_transaction.cpp new file mode 100644 index 0000000..4ba2674 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_transaction.cpp @@ -0,0 +1,50 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IM { +public: + virtual ~IM() {} + virtual void begin() = 0; + virtual void end() = 0; + virtual void a() = 0; + virtual void b() = 0; +}; + +TEST (checkTransactionStyleWorks) +{ + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.autoExpect = false; + Call &beginCall = mocks.ExpectCall(iamock, IM::begin); + Call &aCall = mocks.ExpectCall(iamock, IM::a).After(beginCall); + Call &bCall = mocks.ExpectCall(iamock, IM::b).After(beginCall); + mocks.ExpectCall(iamock, IM::end).After(aCall).After(bCall); + iamock->begin(); + iamock->b(); + iamock->a(); + iamock->end(); +} + +TEST (checkTransactionStyleFailIfOneSkipped) +{ + MockRepository mocks; + IM *iamock = mocks.Mock(); + mocks.autoExpect = false; + Call &beginCall = mocks.ExpectCall(iamock, IM::begin); + Call &aCall = mocks.ExpectCall(iamock, IM::a).After(beginCall); + Call &bCall = mocks.ExpectCall(iamock, IM::b).After(beginCall); + mocks.ExpectCall(iamock, IM::end).After(aCall).After(bCall); + iamock->begin(); + iamock->b(); + bool exceptionCaught = false; + try { + iamock->end(); + } + catch (HippoMocks::ExpectationException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); + mocks.reset(); +} + diff --git a/extlibs/hippomocks-master/HippoMocksTest/test_zombie.cpp b/extlibs/hippomocks-master/HippoMocksTest/test_zombie.cpp new file mode 100644 index 0000000..f1e5422 --- /dev/null +++ b/extlibs/hippomocks-master/HippoMocksTest/test_zombie.cpp @@ -0,0 +1,29 @@ +#include "hippomocks.h" +#include "Framework.h" + +class IZombie { +public: + virtual ~IZombie() {} + virtual void a() = 0; +}; + +TEST (checkZombieCallsAreReported) +{ + bool exceptionCaught = false; + MockRepository mocks; + IZombie *iamock = mocks.Mock(); + mocks.ExpectCall(iamock, IZombie::a); + mocks.ExpectCallDestructor(iamock); + iamock->a(); + delete iamock; + try + { + iamock->a(); + } + catch(HippoMocks::ZombieMockException &) + { + exceptionCaught = true; + } + CHECK(exceptionCaught); +} + diff --git a/extlibs/hippomocks-master/README.md b/extlibs/hippomocks-master/README.md new file mode 100644 index 0000000..20fb2fb --- /dev/null +++ b/extlibs/hippomocks-master/README.md @@ -0,0 +1,5 @@ +Hippomocks +========== + +Single-header mocking framework. + diff --git a/extlibs/hippomocks-master/makefile b/extlibs/hippomocks-master/makefile new file mode 100644 index 0000000..25fe57d --- /dev/null +++ b/extlibs/hippomocks-master/makefile @@ -0,0 +1,9 @@ +all: + $(MAKE) -C HippoMocksTest/ all + +clean: + $(MAKE) -C HippoMocksTest/ clean + +test: + $(MAKE) -C HippoMocksTest/ runtest +

::print(os, p, true); + os << ")"; + } +}; + +template +class ref_comparable_assignable_tuple : public base_tuple +{ +public: + virtual bool operator==(const ref_tuple &bo) = 0; + virtual void assign_from(ref_tuple &from) = 0; + virtual void assign_to(ref_tuple &to) = 0; +}; + +template struct no_array { typedef T type; }; +template struct no_array { typedef T* type; }; + +template +struct store_as +{ + typedef typename no_array::type type; +}; + +template +struct store_as +{ + typedef typename no_array::type type; +}; + +template +class copy_tuple : public ref_comparable_assignable_tuple +{ +public: + typename store_as::type a; + typename store_as::type b; + typename store_as::type c; + typename store_as::type d; + typename store_as::type e; + typename store_as::type f; + typename store_as::type g; + typename store_as::type h; + typename store_as::type i; + typename store_as::type j; + typename store_as::type k; + typename store_as::type l; + typename store_as::type m; + typename store_as::type n; + typename store_as::type o; + typename store_as::type p; + copy_tuple(typename store_as::type valueA, typename store_as::type valueB, + typename store_as::type valueC, typename store_as::type valueD, + typename store_as::type valueE, typename store_as::type valueF, + typename store_as::type valueG, typename store_as::type valueH, + typename store_as::type valueI, typename store_as::type valueJ, + typename store_as::type valueK, typename store_as::type valueL, + typename store_as::type valueM, typename store_as::type valueN, + typename store_as::type valueO, typename store_as::type valueP) + : a(valueA), b(valueB), c(valueC), d(valueD), e(valueE), f(valueF), g(valueG), h(valueH), i(valueI), j(valueJ), k(valueK), l(valueL), m(valueM), n(valueN), o(valueO), p(valueP) + {} + bool operator==(const ref_tuple &to) + { + return (comparer::compare(a, to.a) && + comparer::compare(b, to.b) && + comparer::compare(c, to.c) && + comparer::compare(d, to.d) && + comparer::compare(e, to.e) && + comparer::compare(f, to.f) && + comparer::compare(g, to.g) && + comparer::compare(h, to.h) && + comparer::compare(i, to.i) && + comparer::compare(j, to.j) && + comparer::compare(k, to.k) && + comparer::compare(l, to.l) && + comparer::compare(m, to.m) && + comparer::compare(n, to.n) && + comparer::compare(o, to.o) && + comparer