fixed catch.hpp and fakeit.hpp
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
.idea*
|
*.idea*
|
||||||
cmake-build-debug/*
|
cmake-build-debug/*
|
||||||
|
|||||||
70
.idea/workspace.xml
generated
70
.idea/workspace.xml
generated
@@ -12,7 +12,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e02dc5d7-dead-448e-976e-72d458e813a0" name="Default Changelist" comment="">
|
<list default="true" id="e02dc5d7-dead-448e-976e-72d458e813a0" name="Default Changelist" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/FlippR-Driver/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/FlippR-Driver/CMakeLists.txt" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/FlippR-Driver/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/FlippR-Driver/CMakeLists.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/FlippR-Driver/tests/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/FlippR-Driver/tests/main.cpp" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
|
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
@@ -29,7 +33,7 @@
|
|||||||
<provider selected="true" editor-type-id="text-editor" />
|
<provider selected="true" editor-type-id="text-editor" />
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
<file pinned="false" current-in-tab="true">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/TcpServer.h">
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/TcpServer.h">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="270">
|
<state relative-caret-position="270">
|
||||||
@@ -38,6 +42,24 @@
|
|||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
</file>
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/output/TestDisplay.cpp">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="150">
|
||||||
|
<caret line="10" column="14" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="true">
|
||||||
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="537">
|
||||||
|
<caret line="15003" lean-forward="true" selection-start-line="15003" selection-end-line="15003" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
</leaf>
|
</leaf>
|
||||||
</component>
|
</component>
|
||||||
<component name="FindInProjectRecents">
|
<component name="FindInProjectRecents">
|
||||||
@@ -105,13 +127,14 @@
|
|||||||
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/InputSocketConnection.h" />
|
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/InputSocketConnection.h" />
|
||||||
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/SocketHandler.cpp" />
|
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/SocketHandler.cpp" />
|
||||||
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/SocketHandler.h" />
|
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/SocketHandler.h" />
|
||||||
|
<option value="$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectFrameBounds" extendedState="7">
|
<component name="ProjectFrameBounds" extendedState="6">
|
||||||
<option name="x" value="8" />
|
<option name="x" value="15" />
|
||||||
<option name="width" value="1354" />
|
<option name="width" value="902" />
|
||||||
<option name="height" value="752" />
|
<option name="height" value="496" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectView">
|
<component name="ProjectView">
|
||||||
<navigator proportions="" version="1">
|
<navigator proportions="" version="1">
|
||||||
@@ -290,12 +313,12 @@
|
|||||||
<workItem from="1556129966500" duration="735000" />
|
<workItem from="1556129966500" duration="735000" />
|
||||||
<workItem from="1556134046744" duration="615000" />
|
<workItem from="1556134046744" duration="615000" />
|
||||||
<workItem from="1556134690177" duration="5123000" />
|
<workItem from="1556134690177" duration="5123000" />
|
||||||
<workItem from="1556187501636" duration="2444000" />
|
<workItem from="1556187501636" duration="3653000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="48732000" />
|
<option name="totallyTimeSpent" value="49941000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TodoView">
|
<component name="TodoView">
|
||||||
<todo-panel id="selected-file">
|
<todo-panel id="selected-file">
|
||||||
@@ -307,7 +330,7 @@
|
|||||||
</todo-panel>
|
</todo-panel>
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="0" y="0" width="1366" height="750" extended-state="7" />
|
<frame x="0" y="0" width="1366" height="750" extended-state="6" />
|
||||||
<editor active="true" />
|
<editor active="true" />
|
||||||
<layout>
|
<layout>
|
||||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26287878" />
|
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26287878" />
|
||||||
@@ -358,16 +381,6 @@
|
|||||||
<option name="version" value="1" />
|
<option name="version" value="1" />
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="file://$PROJECT_DIR$/FlippR-Driver/src/output/detail/SoundBoardPinController.h">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="180">
|
|
||||||
<caret line="12" lean-forward="true" selection-start-line="12" selection-end-line="12" />
|
|
||||||
<folding>
|
|
||||||
<element signature="e#164#207#0" expanded="true" />
|
|
||||||
</folding>
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/FlippR-Driver/src/utility/BlockingQueue.hpp">
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/src/utility/BlockingQueue.hpp">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state>
|
<state>
|
||||||
@@ -629,13 +642,6 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp">
|
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
|
||||||
<state relative-caret-position="630">
|
|
||||||
<caret line="5246" column="22" selection-start-line="5246" selection-start-column="22" selection-end-line="5246" selection-end-column="22" />
|
|
||||||
</state>
|
|
||||||
</provider>
|
|
||||||
</entry>
|
|
||||||
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/main.cpp">
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/main.cpp">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="135">
|
<state relative-caret-position="135">
|
||||||
@@ -727,5 +733,19 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/output/TestDisplay.cpp">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="150">
|
||||||
|
<caret line="10" column="14" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="537">
|
||||||
|
<caret line="15003" lean-forward="true" selection-start-line="15003" selection-end-line="15003" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -132,6 +132,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Easylogging)
|
|||||||
|
|
||||||
######################## CATCH ############################
|
######################## CATCH ############################
|
||||||
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tests)
|
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tests)
|
||||||
|
|
||||||
add_library(Catch INTERFACE)
|
add_library(Catch INTERFACE)
|
||||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* FakeIt - A Simplified C++ Mocking Framework
|
* FakeIt - A Simplified C++ Mocking Framework
|
||||||
* Copyright (c) Eran Pe'er 2013
|
* Copyright (c) Eran Pe'er 2013
|
||||||
* Generated: 2017-11-05 20:30:40.182814
|
* Generated: 2018-08-17 00:22:40.428924
|
||||||
* Distributed under the MIT License. Please refer to the LICENSE file at:
|
* Distributed under the MIT License. Please refer to the LICENSE file at:
|
||||||
* https://github.com/eranpeer/FakeIt
|
* https://github.com/eranpeer/FakeIt
|
||||||
*/
|
*/
|
||||||
@@ -253,6 +253,35 @@ namespace fakeit {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Formatter<char const*>
|
||||||
|
{
|
||||||
|
static std::string format(char const* const &val)
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
if(val != nullptr)
|
||||||
|
{
|
||||||
|
s += '"';
|
||||||
|
s += val;
|
||||||
|
s += '"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = "[nullptr]";
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Formatter<char*>
|
||||||
|
{
|
||||||
|
static std::string format(char* const &val)
|
||||||
|
{
|
||||||
|
return Formatter<char const*>::format( val );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class C>
|
template<class C>
|
||||||
struct Formatter<C, typename std::enable_if<!is_ostreamable<C>::value>::type> {
|
struct Formatter<C, typename std::enable_if<!is_ostreamable<C>::value>::type> {
|
||||||
static std::string format(C const &)
|
static std::string format(C const &)
|
||||||
@@ -742,6 +771,9 @@ namespace fakeit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#ifdef FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace fakeit {
|
namespace fakeit {
|
||||||
|
|
||||||
@@ -831,7 +863,7 @@ namespace fakeit {
|
|||||||
out << "Unexpected method invocation: ";
|
out << "Unexpected method invocation: ";
|
||||||
out << e.getInvocation().format() << std::endl;
|
out << e.getInvocation().format() << std::endl;
|
||||||
if (UnexpectedType::Unmatched == e.getUnexpectedType()) {
|
if (UnexpectedType::Unmatched == e.getUnexpectedType()) {
|
||||||
out << " Could not find Any recorded behavior to support this method call.";
|
out << " Could not find any recorded behavior to support this method call.";
|
||||||
} else {
|
} else {
|
||||||
out << " An unmocked method was invoked. All used virtual methods must be stubbed!";
|
out << " An unmocked method was invoked. All used virtual methods must be stubbed!";
|
||||||
}
|
}
|
||||||
@@ -868,7 +900,7 @@ namespace fakeit {
|
|||||||
virtual std::string format(const NoMoreInvocationsVerificationEvent &e) override {
|
virtual std::string format(const NoMoreInvocationsVerificationEvent &e) override {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "Verification error" << std::endl;
|
out << "Verification error" << std::endl;
|
||||||
out << "Expected no more invocations!! But the following unverified invocations were found:" << std::endl;
|
out << "Expected no more invocations!! but the following unverified invocations were found:" << std::endl;
|
||||||
formatInvocationList(out, e.unverifedIvocations());
|
formatInvocationList(out, e.unverifedIvocations());
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
@@ -915,8 +947,8 @@ namespace fakeit {
|
|||||||
|
|
||||||
static void formatInvocationList(std::ostream &out, const std::vector<fakeit::Invocation *> &actualSequence) {
|
static void formatInvocationList(std::ostream &out, const std::vector<fakeit::Invocation *> &actualSequence) {
|
||||||
size_t max_size = actualSequence.size();
|
size_t max_size = actualSequence.size();
|
||||||
if (max_size > 5)
|
if (max_size > 50)
|
||||||
max_size = 5;
|
max_size = 50;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < max_size; i++) {
|
for (unsigned int i = 0; i < max_size; i++) {
|
||||||
out << " ";
|
out << " ";
|
||||||
@@ -1170,12 +1202,13 @@ namespace fakeit {
|
|||||||
std::string fomattedMessage,
|
std::string fomattedMessage,
|
||||||
Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
|
Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
|
||||||
Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
|
Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
|
||||||
INTERNAL_CATCH_TRY( catchAssertionHandler ) { \
|
INTERNAL_CATCH_TRY { \
|
||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
catchAssertionHandler.handle( resultWas , fomattedMessage); \
|
catchAssertionHandler.handleMessage(resultWas, fomattedMessage); \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
||||||
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
} INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
|
||||||
INTERNAL_CATCH_REACT( catchAssertionHandler )
|
INTERNAL_CATCH_REACT(catchAssertionHandler) \
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handle(const UnexpectedMethodCallEvent &evt) override {
|
virtual void handle(const UnexpectedMethodCallEvent &evt) override {
|
||||||
@@ -1237,11 +1270,13 @@ static fakeit::DefaultFakeit& Fakeit = fakeit::CatchFakeit::getInstance();
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#undef max
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -5281,7 +5316,9 @@ namespace fakeit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace fakeit {
|
namespace fakeit {
|
||||||
class NoVirtualDtor {
|
class NoVirtualDtor : public std::runtime_error {
|
||||||
|
public:
|
||||||
|
NoVirtualDtor() :std::runtime_error("Can't mock the destructor. No virtual destructor was found") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class VTUtils {
|
class VTUtils {
|
||||||
@@ -5308,6 +5345,18 @@ namespace fakeit {
|
|||||||
throw NoVirtualDtor();
|
throw NoVirtualDtor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
static typename std::enable_if<std::has_virtual_destructor<C>::value, bool>::type
|
||||||
|
hasVirtualDestructor() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
static typename std::enable_if<!std::has_virtual_destructor<C>::value, bool>::type
|
||||||
|
hasVirtualDestructor() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
static unsigned int getVTSize() {
|
static unsigned int getVTSize() {
|
||||||
struct Derrived : public C {
|
struct Derrived : public C {
|
||||||
@@ -5935,6 +5984,10 @@ namespace fakeit {
|
|||||||
std::vector<std::shared_ptr<Destructible>> &methodMocks,
|
std::vector<std::shared_ptr<Destructible>> &methodMocks,
|
||||||
std::vector<unsigned int> &offsets) :
|
std::vector<unsigned int> &offsets) :
|
||||||
_methodMocks(methodMocks), _offsets(offsets) {
|
_methodMocks(methodMocks), _offsets(offsets) {
|
||||||
|
for (std::vector<unsigned int>::iterator it = _offsets.begin(); it != _offsets.end(); ++it)
|
||||||
|
{
|
||||||
|
*it = std::numeric_limits<int>::max();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Destructible *getInvocatoinHandlerPtrById(unsigned int id) override {
|
Destructible *getInvocatoinHandlerPtrById(unsigned int id) override {
|
||||||
@@ -7900,22 +7953,13 @@ namespace fakeit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MockImpl(FakeitContext &fakeit)
|
MockImpl(FakeitContext &fakeit)
|
||||||
: MockImpl<C, baseclasses...>(fakeit, *(createFakeInstance()), false) {
|
: MockImpl<C, baseclasses...>(fakeit, *(createFakeInstance()), false){
|
||||||
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(_instance);
|
FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
|
||||||
fake->getVirtualTable().setCookie(1, this);
|
fake->getVirtualTable().setCookie(1, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~MockImpl() NO_THROWS {
|
virtual ~MockImpl() NO_THROWS {
|
||||||
_proxy.detach();
|
_proxy.detach();
|
||||||
if (_isOwner) {
|
|
||||||
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(_instance);
|
|
||||||
delete fake;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void detach() {
|
|
||||||
_isOwner = false;
|
|
||||||
_proxy.detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -7929,8 +7973,8 @@ namespace fakeit {
|
|||||||
|
|
||||||
void initDataMembersIfOwner()
|
void initDataMembersIfOwner()
|
||||||
{
|
{
|
||||||
if (_isOwner) {
|
if (isOwner()) {
|
||||||
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(_instance);
|
FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
|
||||||
fake->initializeDataMembersArea();
|
fake->initializeDataMembersArea();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7974,12 +8018,35 @@ namespace fakeit {
|
|||||||
return DtorMockingContext(new DtorMockingContextImpl(*this));
|
return DtorMockingContext(new DtorMockingContextImpl(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<FakeObject<C, baseclasses...>> _instanceOwner;
|
||||||
DynamicProxy<C, baseclasses...> _proxy;
|
DynamicProxy<C, baseclasses...> _proxy;
|
||||||
C *_instance;
|
|
||||||
bool _isOwner;
|
|
||||||
FakeitContext &_fakeit;
|
FakeitContext &_fakeit;
|
||||||
|
|
||||||
|
MockImpl(FakeitContext &fakeit, C &obj, bool isSpy)
|
||||||
|
: _instanceOwner(isSpy ? nullptr : asFakeObject(&obj))
|
||||||
|
, _proxy{obj}
|
||||||
|
, _fakeit(fakeit) {}
|
||||||
|
|
||||||
|
static FakeObject<C, baseclasses...>* asFakeObject(void* instance){
|
||||||
|
return reinterpret_cast<FakeObject<C, baseclasses...> *>(instance);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename R, typename ... arglist>
|
template<typename R, typename ... arglist>
|
||||||
class MethodMockingContextBase : public MethodMockingContext<R, arglist...>::Context {
|
class MethodMockingContextBase : public MethodMockingContext<R, arglist...>::Context {
|
||||||
protected:
|
protected:
|
||||||
@@ -8086,12 +8153,16 @@ namespace fakeit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static MockImpl<C, baseclasses...> *getMockImpl(void *instance) {
|
static MockImpl<C, baseclasses...> *getMockImpl(void *instance) {
|
||||||
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(instance);
|
FakeObject<C, baseclasses...> *fake = asFakeObject(instance);
|
||||||
MockImpl<C, baseclasses...> *mock = reinterpret_cast<MockImpl<C, baseclasses...> *>(fake->getVirtualTable().getCookie(
|
MockImpl<C, baseclasses...> *mock = reinterpret_cast<MockImpl<C, baseclasses...> *>(fake->getVirtualTable().getCookie(
|
||||||
1));
|
1));
|
||||||
return mock;
|
return mock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isOwner(){ return _instanceOwner != nullptr;}
|
||||||
|
|
||||||
|
void unmockedDtor() {}
|
||||||
|
|
||||||
void unmocked() {
|
void unmocked() {
|
||||||
ActualInvocation<> invocation(Invocation::nextInvocationOrdinal(), UnknownMethod::instance());
|
ActualInvocation<> invocation(Invocation::nextInvocationOrdinal(), UnknownMethod::instance());
|
||||||
UnexpectedMethodCallEvent event(UnexpectedType::Unmocked, invocation);
|
UnexpectedMethodCallEvent event(UnexpectedType::Unmocked, invocation);
|
||||||
@@ -8106,7 +8177,10 @@ namespace fakeit {
|
|||||||
static C *createFakeInstance() {
|
static C *createFakeInstance() {
|
||||||
FakeObject<C, baseclasses...> *fake = new FakeObject<C, baseclasses...>();
|
FakeObject<C, baseclasses...> *fake = new FakeObject<C, baseclasses...>();
|
||||||
void *unmockedMethodStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmocked);
|
void *unmockedMethodStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmocked);
|
||||||
|
void *unmockedDtorStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmockedDtor);
|
||||||
fake->getVirtualTable().initAll(unmockedMethodStubPtr);
|
fake->getVirtualTable().initAll(unmockedMethodStubPtr);
|
||||||
|
if (VTUtils::hasVirtualDestructor<C>())
|
||||||
|
fake->setDtor(unmockedDtorStubPtr);
|
||||||
return reinterpret_cast<C *>(fake);
|
return reinterpret_cast<C *>(fake);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8145,10 +8219,6 @@ namespace fakeit {
|
|||||||
return *dtorMock;
|
return *dtorMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
MockImpl(FakeitContext &fakeit, C &obj, bool isSpy)
|
|
||||||
: _proxy{obj}, _instance(&obj), _isOwner(!isSpy), _fakeit(fakeit) {
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename R, typename ... arglist>
|
template<typename R, typename ... arglist>
|
||||||
static RecordedMethodBody<R, arglist...> *createRecordedMethodBody(MockObject<C> &mock,
|
static RecordedMethodBody<R, arglist...> *createRecordedMethodBody(MockObject<C> &mock,
|
||||||
R(C::*vMethod)(arglist...)) {
|
R(C::*vMethod)(arglist...)) {
|
||||||
@@ -8158,7 +8228,6 @@ namespace fakeit {
|
|||||||
static RecordedMethodBody<void> *createRecordedDtorBody(MockObject<C> &mock) {
|
static RecordedMethodBody<void> *createRecordedDtorBody(MockObject<C> &mock) {
|
||||||
return new RecordedMethodBody<void>(mock.getFakeIt(), "dtor");
|
return new RecordedMethodBody<void>(mock.getFakeIt(), "dtor");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
namespace fakeit {
|
namespace fakeit {
|
||||||
@@ -8232,6 +8301,10 @@ namespace fakeit {
|
|||||||
return impl.get();
|
return impl.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
C &operator()() {
|
C &operator()() {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
@@ -8753,12 +8826,12 @@ namespace fakeit {
|
|||||||
return !isAtLeastVerification();
|
return !isAtLeastVerification();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atLeastLimitNotReached(int count) {
|
bool atLeastLimitNotReached(int actualCount) {
|
||||||
return count < -_expectedCount;
|
return actualCount < -_expectedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exactLimitNotMatched(int count) {
|
bool exactLimitNotMatched(int actualCount) {
|
||||||
return count != _expectedCount;
|
return actualCount != _expectedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleExactVerificationEvent(VerificationEventHandler &verificationErrorHandler,
|
void handleExactVerificationEvent(VerificationEventHandler &verificationErrorHandler,
|
||||||
@@ -8850,7 +8923,7 @@ namespace fakeit {
|
|||||||
|
|
||||||
~SequenceVerificationProgress() THROWS { };
|
~SequenceVerificationProgress() THROWS { };
|
||||||
|
|
||||||
operator bool() {
|
operator bool() const {
|
||||||
return Terminator(_expectationPtr);
|
return Terminator(_expectationPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9105,8 +9178,8 @@ namespace fakeit {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() {
|
operator bool() const {
|
||||||
return toBool();
|
return const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!() const { return !const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool(); }
|
bool operator!() const { return !const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool(); }
|
||||||
@@ -9300,4 +9373,3 @@ namespace fakeit {
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define CATCH_CONFIG_MAIN
|
#define CATCH_CONFIG_MAIN
|
||||||
//#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|||||||
Reference in New Issue
Block a user