fixed catch.hpp and fakeit.hpp

This commit is contained in:
Johannes Wendel
2019-04-25 15:23:16 +02:00
parent 6dbf10c623
commit 79e608b4d7
6 changed files with 11748 additions and 8664 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
.idea*
*.idea*
cmake-build-debug/*

70
.idea/workspace.xml generated
View File

@@ -12,7 +12,11 @@
</component>
<component name="ChangeListManager">
<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/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>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -29,7 +33,7 @@
<provider selected="true" editor-type-id="text-editor" />
</entry>
</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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
@@ -38,6 +42,24 @@
</provider>
</entry>
</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>
</component>
<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/SocketHandler.cpp" />
<option value="$PROJECT_DIR$/FlippR-Driver/src/utility/networking/input/SocketHandler.h" />
<option value="$PROJECT_DIR$/FlippR-Driver/tests/catch.hpp" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="8" />
<option name="width" value="1354" />
<option name="height" value="752" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="15" />
<option name="width" value="902" />
<option name="height" value="496" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
@@ -290,12 +313,12 @@
<workItem from="1556129966500" duration="735000" />
<workItem from="1556134046744" duration="615000" />
<workItem from="1556134690177" duration="5123000" />
<workItem from="1556187501636" duration="2444000" />
<workItem from="1556187501636" duration="3653000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="48732000" />
<option name="totallyTimeSpent" value="49941000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@@ -307,7 +330,7 @@
</todo-panel>
</component>
<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" />
<layout>
<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" />
</component>
<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">
<provider selected="true" editor-type-id="text-editor">
<state>
@@ -629,13 +642,6 @@
</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="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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
@@ -727,5 +733,19 @@
</state>
</provider>
</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>
</project>

View File

@@ -132,6 +132,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Easylogging)
######################## CATCH ############################
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tests)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* 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:
* 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>
struct Formatter<C, typename std::enable_if<!is_ostreamable<C>::value>::type> {
static std::string format(C const &)
@@ -742,6 +771,9 @@ namespace fakeit {
};
}
#ifdef FAKEIT_ASSERT_ON_UNEXPECTED_METHOD_INVOCATION
#include <cassert>
#endif
namespace fakeit {
@@ -831,7 +863,7 @@ namespace fakeit {
out << "Unexpected method invocation: ";
out << e.getInvocation().format() << std::endl;
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 {
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 {
std::ostringstream out;
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());
return out.str();
}
@@ -915,8 +947,8 @@ namespace fakeit {
static void formatInvocationList(std::ostream &out, const std::vector<fakeit::Invocation *> &actualSequence) {
size_t max_size = actualSequence.size();
if (max_size > 5)
max_size = 5;
if (max_size > 50)
max_size = 50;
for (unsigned int i = 0; i < max_size; i++) {
out << " ";
@@ -1170,12 +1202,13 @@ namespace fakeit {
std::string fomattedMessage,
Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
INTERNAL_CATCH_TRY( catchAssertionHandler ) { \
INTERNAL_CATCH_TRY { \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
catchAssertionHandler.handle( resultWas , fomattedMessage); \
catchAssertionHandler.handleMessage(resultWas, fomattedMessage); \
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
INTERNAL_CATCH_REACT( catchAssertionHandler )
} INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
INTERNAL_CATCH_REACT(catchAssertionHandler) \
}
}
virtual void handle(const UnexpectedMethodCallEvent &evt) override {
@@ -1237,11 +1270,13 @@ static fakeit::DefaultFakeit& Fakeit = fakeit::CatchFakeit::getInstance();
#include <unordered_set>
#include <memory>
#undef max
#include <functional>
#include <type_traits>
#include <vector>
#include <array>
#include <new>
#include <limits>
#include <functional>
#include <type_traits>
@@ -5281,7 +5316,9 @@ 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 {
@@ -5308,6 +5345,18 @@ namespace fakeit {
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>
static unsigned int getVTSize() {
struct Derrived : public C {
@@ -5935,6 +5984,10 @@ namespace fakeit {
std::vector<std::shared_ptr<Destructible>> &methodMocks,
std::vector<unsigned int> &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 {
@@ -7900,22 +7953,13 @@ namespace fakeit {
}
MockImpl(FakeitContext &fakeit)
: MockImpl<C, baseclasses...>(fakeit, *(createFakeInstance()), false) {
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(_instance);
: MockImpl<C, baseclasses...>(fakeit, *(createFakeInstance()), false){
FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
fake->getVirtualTable().setCookie(1, this);
}
virtual ~MockImpl() NO_THROWS {
_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()
{
if (_isOwner) {
FakeObject<C, baseclasses...> *fake = reinterpret_cast<FakeObject<C, baseclasses...> *>(_instance);
if (isOwner()) {
FakeObject<C, baseclasses...> *fake = asFakeObject(_instanceOwner.get());
fake->initializeDataMembersArea();
}
}
@@ -7974,12 +8018,35 @@ namespace fakeit {
return DtorMockingContext(new DtorMockingContextImpl(*this));
}
private:
DynamicProxy<C, baseclasses...> _proxy;
C *_instance;
bool _isOwner;
std::shared_ptr<FakeObject<C, baseclasses...>> _instanceOwner;
DynamicProxy<C, baseclasses...> _proxy;
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>
class MethodMockingContextBase : public MethodMockingContext<R, arglist...>::Context {
protected:
@@ -8086,12 +8153,16 @@ namespace fakeit {
};
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(
1));
return mock;
}
bool isOwner(){ return _instanceOwner != nullptr;}
void unmockedDtor() {}
void unmocked() {
ActualInvocation<> invocation(Invocation::nextInvocationOrdinal(), UnknownMethod::instance());
UnexpectedMethodCallEvent event(UnexpectedType::Unmocked, invocation);
@@ -8106,8 +8177,11 @@ namespace fakeit {
static C *createFakeInstance() {
FakeObject<C, baseclasses...> *fake = new FakeObject<C, baseclasses...>();
void *unmockedMethodStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmocked);
fake->getVirtualTable().initAll(unmockedMethodStubPtr);
return reinterpret_cast<C *>(fake);
void *unmockedDtorStubPtr = union_cast<void *>(&MockImpl<C, baseclasses...>::unmockedDtor);
fake->getVirtualTable().initAll(unmockedMethodStubPtr);
if (VTUtils::hasVirtualDestructor<C>())
fake->setDtor(unmockedDtorStubPtr);
return reinterpret_cast<C *>(fake);
}
template<typename R, typename ... arglist>
@@ -8145,10 +8219,6 @@ namespace fakeit {
return *dtorMock;
}
MockImpl(FakeitContext &fakeit, C &obj, bool isSpy)
: _proxy{obj}, _instance(&obj), _isOwner(!isSpy), _fakeit(fakeit) {
}
template<typename R, typename ... arglist>
static RecordedMethodBody<R, arglist...> *createRecordedMethodBody(MockObject<C> &mock,
R(C::*vMethod)(arglist...)) {
@@ -8158,7 +8228,6 @@ namespace fakeit {
static RecordedMethodBody<void> *createRecordedDtorBody(MockObject<C> &mock) {
return new RecordedMethodBody<void>(mock.getFakeIt(), "dtor");
}
};
}
namespace fakeit {
@@ -8232,7 +8301,11 @@ namespace fakeit {
return impl.get();
}
C &operator()() {
C &operator()() {
return get();
}
@@ -8753,12 +8826,12 @@ namespace fakeit {
return !isAtLeastVerification();
}
bool atLeastLimitNotReached(int count) {
return count < -_expectedCount;
bool atLeastLimitNotReached(int actualCount) {
return actualCount < -_expectedCount;
}
bool exactLimitNotMatched(int count) {
return count != _expectedCount;
bool exactLimitNotMatched(int actualCount) {
return actualCount != _expectedCount;
}
void handleExactVerificationEvent(VerificationEventHandler &verificationErrorHandler,
@@ -8850,7 +8923,7 @@ namespace fakeit {
~SequenceVerificationProgress() THROWS { };
operator bool() {
operator bool() const {
return Terminator(_expectationPtr);
}
@@ -9105,8 +9178,8 @@ namespace fakeit {
return *this;
}
operator bool() {
return toBool();
operator bool() const {
return const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool();
}
bool operator!() const { return !const_cast<VerifyNoOtherInvocationsVerificationProgress *>(this)->toBool(); }
@@ -9300,4 +9373,3 @@ namespace fakeit {
#endif

View File

@@ -6,4 +6,4 @@
*/
#define CATCH_CONFIG_MAIN
//#include "catch.hpp"
#include "catch.hpp"