Skip to content

Commit 98979d2

Browse files
committed
Merge branch 'dev-2.1.0'
2 parents 80a446b + c523986 commit 98979d2

File tree

20 files changed

+5681
-111
lines changed

20 files changed

+5681
-111
lines changed

config/catch/CatchFakeit.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#include "mockutils/to_string.hpp"
66
#if __has_include("catch2/catch.hpp")
77
# include <catch2/catch.hpp>
8+
#elif __has_include("catch2/catch_all.hpp")
9+
# include <catch2/catch_assertion_result.hpp>
10+
# include <catch2/catch_test_macros.hpp>
11+
#elif __has_include("catch_amalgamated.hpp")
12+
# include <catch_amalgamated.hpp>
813
#else
914
# include <catch.hpp>
1015
#endif
@@ -91,6 +96,7 @@ namespace fakeit {
9196
std::string fomattedMessage,
9297
Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
9398
Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
99+
#if defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) && defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION)
94100
INTERNAL_CATCH_TRY { \
95101
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
96102
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
@@ -99,6 +105,15 @@ namespace fakeit {
99105
} INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
100106
INTERNAL_CATCH_REACT(catchAssertionHandler) \
101107
}
108+
#else
109+
INTERNAL_CATCH_TRY { \
110+
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
111+
catchAssertionHandler.handleMessage(resultWas, fomattedMessage); \
112+
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
113+
} INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
114+
INTERNAL_CATCH_REACT(catchAssertionHandler) \
115+
}
116+
#endif
102117
}
103118

104119
virtual void handle(const UnexpectedMethodCallEvent &evt) override {

include/fakeit/MockImpl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ namespace fakeit {
226226
}
227227

228228
virtual std::function<void()> getOriginalMethod() override {
229-
C &instance = MethodMockingContextBase<void>::_mock.get();
230-
return [=, &instance]() -> void {
229+
return [=]() -> void {
231230
};
232231
}
233232

include/fakeit/SequenceVerificationExpectation.hpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ namespace fakeit {
2727
_expectedCount = count;
2828
}
2929

30+
void expectAnything() {
31+
_expectAnything = true;
32+
}
33+
3034
void setFileInfo(const char * file, int line, const char * callingMethod) {
3135
_file = file;
3236
_line = line;
@@ -39,6 +43,7 @@ namespace fakeit {
3943
InvocationsSourceProxy _involvedInvocationSources;
4044
std::vector<Sequence *> _expectedPattern;
4145
int _expectedCount;
46+
bool _expectAnything;
4247

4348
const char * _file;
4449
int _line;
@@ -53,6 +58,7 @@ namespace fakeit {
5358
_involvedInvocationSources(mocks),
5459
_expectedPattern(expectedPattern), //
5560
_expectedCount(-1), // AT_LEAST_ONCE
61+
_expectAnything(false),
5662
_line(0),
5763
_isVerified(false) {
5864
}
@@ -66,12 +72,14 @@ namespace fakeit {
6672
MatchAnalysis ma;
6773
ma.run(_involvedInvocationSources, _expectedPattern);
6874

69-
if (isAtLeastVerification() && atLeastLimitNotReached(ma.count)) {
70-
return handleAtLeastVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
71-
}
75+
if (isNotAnythingVerification()) {
76+
if (isAtLeastVerification() && atLeastLimitNotReached(ma.count)) {
77+
return handleAtLeastVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
78+
}
7279

73-
if (isExactVerification() && exactLimitNotMatched(ma.count)) {
74-
return handleExactVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
80+
if (isExactVerification() && exactLimitNotMatched(ma.count)) {
81+
return handleExactVerificationEvent(verificationErrorHandler, ma.actualSequence, ma.count);
82+
}
7583
}
7684

7785
markAsVerified(ma.matchedInvocations);
@@ -95,6 +103,10 @@ namespace fakeit {
95103
}
96104
}
97105

106+
bool isNotAnythingVerification() {
107+
return !_expectAnything;
108+
}
109+
98110
bool isAtLeastVerification() {
99111
// negative number represents an "AtLeast" search;
100112
return _expectedCount < 0;

include/fakeit/SequenceVerificationProgress.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ namespace fakeit {
7070

7171
bool operator!() const { return !Terminator(_expectationPtr); }
7272

73+
Terminator Any() {
74+
_expectationPtr->expectAnything();
75+
return Terminator(_expectationPtr);
76+
}
77+
7378
Terminator Never() {
7479
Exactly(0);
7580
return Terminator(_expectationPtr);

0 commit comments

Comments
 (0)