-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
10,620 additions
and
609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#pragma once | ||
|
||
#include "fakeit/DefaultFakeit.hpp" | ||
#include "fakeit/EventHandler.hpp" | ||
#include "mockutils/to_string.hpp" | ||
#include <doctest.h> | ||
|
||
namespace fakeit | ||
{ | ||
class DoctestAdapter : public EventHandler | ||
{ | ||
EventFormatter &_formatter; | ||
|
||
public: | ||
virtual ~DoctestAdapter() = default; | ||
|
||
DoctestAdapter(EventFormatter &formatter) | ||
: _formatter(formatter) {} | ||
|
||
void fail(const char* fileName, | ||
int lineNumber, | ||
std::string fomattedMessage, | ||
bool fatalFailure) | ||
{ | ||
if (fatalFailure) | ||
{ | ||
DOCTEST_ADD_FAIL_AT(fileName, lineNumber, fomattedMessage); | ||
} | ||
else | ||
{ | ||
DOCTEST_ADD_FAIL_CHECK_AT(fileName, lineNumber, fomattedMessage); | ||
} | ||
} | ||
|
||
void handle(const UnexpectedMethodCallEvent &evt) override | ||
{ | ||
fail("Unknown file", 0, _formatter.format(evt), true); | ||
} | ||
|
||
void handle(const SequenceVerificationEvent &evt) override | ||
{ | ||
fail(evt.file(), evt.line(), _formatter.format(evt), false); | ||
} | ||
|
||
void handle(const NoMoreInvocationsVerificationEvent &evt) override | ||
{ | ||
fail(evt.file(), evt.line(), _formatter.format(evt), false); | ||
} | ||
}; | ||
|
||
class DoctestFakeit : public DefaultFakeit | ||
{ | ||
public: | ||
virtual ~DoctestFakeit() = default; | ||
|
||
DoctestFakeit() : _doctestAdapter(*this) {} | ||
|
||
static DoctestFakeit &getInstance() | ||
{ | ||
static DoctestFakeit instance; | ||
return instance; | ||
} | ||
|
||
protected: | ||
fakeit::EventHandler &accessTestingFrameworkAdapter() override | ||
{ | ||
return _doctestAdapter; | ||
} | ||
|
||
private: | ||
DoctestAdapter _doctestAdapter; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef fakeit_h__ | ||
#define fakeit_h__ | ||
|
||
#include "fakeit_instance.hpp" | ||
#include "fakeit/fakeit_root.hpp" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "DoctestFakeit.hpp" | ||
|
||
static fakeit::DefaultFakeit& Fakeit = fakeit::DoctestFakeit::getInstance(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
*/ | ||
#pragma once | ||
|
||
#include <cmath> | ||
#include <cstring> | ||
|
||
#include "mockutils/type_utils.hpp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.