Skip to content

Commit

Permalink
Merge branch 'dev-2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Dec 2, 2022
2 parents 78ca536 + 1154378 commit 49b27fe
Show file tree
Hide file tree
Showing 51 changed files with 1,559 additions and 1,027 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Debug/
ipch/
TestResults/
tests/cmake-build-debug/
tests/x64/
*/.vs/

# Eclipse
Expand Down Expand Up @@ -59,3 +60,4 @@ bii/

*.*~
*.nupkg

8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
image:
- Visual Studio 2019
- Visual Studio 2015

configuration:
- Debug
- Release

build:
project: tests\all_tests.sln
1 change: 1 addition & 0 deletions build/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CPP_SRCS += \
gcc_stubbing_multiple_values_tests.cpp \
gcc_type_info_tests.cpp \
miscellaneous_tests.cpp \
move_only_return_tests.cpp \
msc_stubbing_multiple_values_tests.cpp \
msc_type_info_tests.cpp \
overloadded_methods_tests.cpp \
Expand Down
4 changes: 2 additions & 2 deletions config/standalone/StandaloneFakeit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace fakeit {

struct VerificationException : public std::exception {
virtual ~VerificationException() NO_THROWS{};
virtual ~VerificationException() FAKEIT_NO_THROWS{};

VerificationException(std::string format) : //
_format(format) { //
Expand All @@ -33,7 +33,7 @@ namespace fakeit {
return _callingMethod;
}

const char* what() const NO_THROWS override{
const char* what() const FAKEIT_NO_THROWS override{
return _format.c_str();
}
private:
Expand Down
4 changes: 2 additions & 2 deletions config/tpunit/TpUnitFakeit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class TpUnitAdapter: public EventHandler {
: _msg(msg) {
}

const char* what() const NO_THROWS override{
const char* what() const FAKEIT_NO_THROWS override{
return _msg.c_str();
}

virtual ~AssertionException() NO_THROWS {}
virtual ~AssertionException() FAKEIT_NO_THROWS {}
};

virtual ~TpUnitAdapter() = default;
Expand Down
5 changes: 5 additions & 0 deletions include/fakeit/ActionSequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ namespace fakeit {
Action<R, arglist...> &action = dynamic_cast<Action<R, arglist...> &>(destructable);
std::function<void()> finallyClause = [&]() -> void {
if (action.isDone())
{
_recordedActions.erase(_recordedActions.begin());
_usedActions.push_back(destructablePtr);
}
};
Finally onExit(finallyClause);
return action.invoke(args);
Expand Down Expand Up @@ -76,11 +79,13 @@ namespace fakeit {

void clear() {
_recordedActions.clear();
_usedActions.clear();
auto actionPtr = std::shared_ptr<Destructible> {new NoMoreRecordedAction()};
_recordedActions.push_back(actionPtr);
}

std::vector<std::shared_ptr<Destructible>> _recordedActions;
std::vector<std::shared_ptr<Destructible>> _usedActions;
};

}
4 changes: 2 additions & 2 deletions include/fakeit/ActualInvocationsSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace fakeit {
struct ActualInvocationsContainer {
virtual void clear() = 0;

virtual ~ActualInvocationsContainer() NO_THROWS { }
virtual ~ActualInvocationsContainer() FAKEIT_NO_THROWS { }
};

struct ActualInvocationsSource {
virtual void getActualInvocations(std::unordered_set<fakeit::Invocation *> &into) const = 0;

virtual ~ActualInvocationsSource() NO_THROWS { }
virtual ~ActualInvocationsSource() FAKEIT_NO_THROWS { }
};

struct InvocationsSourceProxy : public ActualInvocationsSource {
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/DomainObjects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace fakeit {

template<typename C>
struct MockObject {
virtual ~MockObject() THROWS { };
virtual ~MockObject() FAKEIT_THROWS { };

virtual C &get() = 0;

Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/Invocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace fakeit {

struct Matcher {

virtual ~Matcher() THROWS {
virtual ~Matcher() FAKEIT_THROWS {
}

virtual bool matches(Invocation &invocation) = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/MethodMockingContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace fakeit {
: _impl(std::move(other._impl)) {
}

virtual ~MethodMockingContext() NO_THROWS { }
virtual ~MethodMockingContext() FAKEIT_NO_THROWS { }

std::string format() const override {
return _impl->format();
Expand Down
6 changes: 3 additions & 3 deletions include/fakeit/Mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ namespace fakeit {
impl.clear();
}

template<class DATA_TYPE, typename ... arglist,
class = typename std::enable_if<std::is_member_object_pointer<DATA_TYPE C::*>::value>::type>
DataMemberStubbingRoot<C, DATA_TYPE> Stub(DATA_TYPE C::* member, const arglist &... ctorargs) {
template<class DataType, typename ... arglist,
class = typename std::enable_if<std::is_member_object_pointer<DataType C::*>::value>::type>
DataMemberStubbingRoot<C, DataType> Stub(DataType C::* member, const arglist &... ctorargs) {
return impl.stubDataMember(member, ctorargs...);
}

Expand Down
10 changes: 5 additions & 5 deletions include/fakeit/MockImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace fakeit {
fake->getVirtualTable().setCookie(1, this);
}

virtual ~MockImpl() NO_THROWS {
virtual ~MockImpl() FAKEIT_NO_THROWS {
_proxy.detach();
}

Expand Down Expand Up @@ -83,10 +83,10 @@ namespace fakeit {
return _fakeit;
}

template<class DATA_TYPE, typename T, typename ... arglist, class = typename std::enable_if<std::is_base_of<T, C>::value>::type>
DataMemberStubbingRoot<C, DATA_TYPE> stubDataMember(DATA_TYPE T::*member, const arglist &... ctorargs) {
template<class DataType, typename T, typename ... arglist, class = typename std::enable_if<std::is_base_of<T, C>::value>::type>
DataMemberStubbingRoot<C, DataType> stubDataMember(DataType T::*member, const arglist &... ctorargs) {
_proxy.stubDataMember(member, ctorargs...);
return DataMemberStubbingRoot<T, DATA_TYPE>();
return DataMemberStubbingRoot<T, DataType>();
}

template<int id, typename R, typename T, typename ... arglist, class = typename std::enable_if<std::is_base_of<T, C>::value>::type>
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace fakeit {
: MethodMockingContextBase<R, arglist...>(mock), _vMethod(vMethod) {
}

template<typename ... T, typename std::enable_if<all_true<std::is_copy_constructible<T>::value...>::value, int>::type = 0>
template<typename ... T, typename std::enable_if<all_true<smart_is_copy_constructible<T>::value...>::value, int>::type = 0>
std::function<R(arglist&...)> getOriginalMethodCopyArgsInternal(int) {
void *mPtr = MethodMockingContextBase<R, arglist...>::_mock.getOriginalMethod(_vMethod);
C * instance = &(MethodMockingContextBase<R, arglist...>::_mock.get());
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/RecordedMethodBody.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace fakeit {
RecordedMethodBody(FakeitContext &fakeit, std::string name) :
_fakeit(fakeit), _method{MethodInfo::nextMethodOrdinal(), name} { }

virtual ~RecordedMethodBody() NO_THROWS {
virtual ~RecordedMethodBody() FAKEIT_NO_THROWS {
}

MethodInfo &getMethod() {
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/Sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace fakeit {
Sequence() {
}

virtual ~Sequence() THROWS {
virtual ~Sequence() FAKEIT_THROWS {
}

public:
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/SequenceVerificationExpectation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace fakeit {

friend class SequenceVerificationProgress;

~SequenceVerificationExpectation() THROWS {
~SequenceVerificationExpectation() FAKEIT_THROWS {
if (UncaughtException()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/SequenceVerificationProgress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace fakeit {

public:

~SequenceVerificationProgress() THROWS { };
~SequenceVerificationProgress() FAKEIT_THROWS { };

operator bool() const {
return Terminator(_expectationPtr);
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/SpyFunctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace fakeit {
class SpyFunctor {
private:

template<typename R, typename ... arglist, typename std::enable_if<all_true<std::is_copy_constructible<arglist>::value...>::value, int>::type = 0>
template<typename R, typename ... arglist, typename std::enable_if<all_true<smart_is_copy_constructible<arglist>::value...>::value, int>::type = 0>
void spy(const SpyingContext<R, arglist...> &root, int) {
SpyingContext<R, arglist...> &rootWithoutConst = const_cast<SpyingContext<R, arglist...> &>(root);
auto methodFromOriginalVT = rootWithoutConst.getOriginalMethodCopyArgs();
Expand Down
4 changes: 2 additions & 2 deletions include/fakeit/StubbingImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace fakeit {

template<typename C, typename DATA_TYPE>
template<typename C, typename DataType>
class DataMemberStubbingRoot {
private:
//DataMemberStubbingRoot & operator= (const DataMemberStubbingRoot & other) = delete;
Expand All @@ -30,7 +30,7 @@ namespace fakeit {

DataMemberStubbingRoot() = default;

void operator=(const DATA_TYPE&) {
void operator=(const DataType&) {
}
};

Expand Down
23 changes: 16 additions & 7 deletions include/fakeit/StubbingProgress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace fakeit {
template<typename R, typename ... arglist>
struct MethodStubbingProgress {

virtual ~MethodStubbingProgress() THROWS {
virtual ~MethodStubbingProgress() FAKEIT_THROWS {
}

template<typename U = R>
Expand All @@ -59,6 +59,15 @@ namespace fakeit {
return Do([&r](const typename fakeit::test_arg<arglist>::type...) -> R { return r; });
}

template<typename U = R>
typename std::enable_if<!std::is_copy_constructible<U>::value, MethodStubbingProgress<R, arglist...>&>::type
Return(R&& r) {
auto store = std::make_shared<R>(std::move(r)); // work around for lack of move_only_funciton( C++23) - move into a shared_ptr which we can copy.
return Do([store](const typename fakeit::test_arg<arglist>::type...) mutable -> R {
return std::move(*store);
});
}

MethodStubbingProgress<R, arglist...> &
Return(const Quantifier<R> &q) {
const R &value = q.value;
Expand Down Expand Up @@ -220,7 +229,7 @@ namespace fakeit {
template<typename ... arglist>
struct MethodStubbingProgress<void, arglist...> {

virtual ~MethodStubbingProgress() THROWS {
virtual ~MethodStubbingProgress() FAKEIT_THROWS {
}

MethodStubbingProgress<void, arglist...> &Return() {
Expand Down Expand Up @@ -373,7 +382,7 @@ namespace fakeit {
template <typename ...T, int ...N>
static void CheckPositions(const std::tuple<ArgValue<T, N>...> arg_vals)
{
#if __cplusplus >= 201402L
#if __cplusplus >= 201402L && !defined(_WIN32)
static_assert(std::get<tuple_index>(arg_vals).pos <= max_index,
"Argument index out of range");
ArgValidator<max_index, tuple_index - 1>::CheckPositions(arg_vals);
Expand Down Expand Up @@ -425,7 +434,7 @@ namespace fakeit {
struct ArgLocator {
template<typename current_arg, typename ...T, int ...N>
static void AssignArg(current_arg &&p, std::tuple<ArgValue<T, N>...> arg_vals) {
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && !defined (_WIN32)
if constexpr (std::get<check_index>(arg_vals).pos == arg_index)
GetArg(std::forward<current_arg>(p)) = std::get<check_index>(arg_vals).value;
#else
Expand All @@ -436,19 +445,19 @@ namespace fakeit {
ArgLocator<arg_index, check_index - 1>::AssignArg(std::forward<current_arg>(p), arg_vals);
}

#if __cplusplus < 201703L
#if __cplusplus < 201703L || defined (_WIN32)
private:
template<typename T, typename U>
static
typename std::enable_if<std::is_convertible<U, decltype(GetArg(std::declval<T>()))>::value, void>::type
typename std::enable_if<std::is_assignable<decltype(GetArg(std::declval<T>())), U>::value, void>::type
Set(T &&p, U &&v)
{
GetArg(std::forward<T>(p)) = v;
}

template<typename T, typename U>
static
typename std::enable_if<!std::is_convertible<U, decltype(GetArg(std::declval<T>()))>::value, void>::type
typename std::enable_if<!std::is_assignable<decltype(GetArg(std::declval<T>())), U>::value, void>::type
Set(T &&, U &&)
{
throw std::logic_error("ReturnAndSet(): Invalid value type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace fakeit {

friend class VerifyNoOtherInvocationsVerificationProgress;

~VerifyNoOtherInvocationsExpectation() THROWS {
~VerifyNoOtherInvocationsExpectation() FAKEIT_THROWS {
if (UncaughtException()) {
return;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace fakeit {
public:


~VerifyNoOtherInvocationsVerificationProgress() THROWS {
~VerifyNoOtherInvocationsVerificationProgress() FAKEIT_THROWS {
};

VerifyNoOtherInvocationsVerificationProgress setFileInfo(const char * file, int line,
Expand Down
2 changes: 1 addition & 1 deletion include/fakeit/WhenFunctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace fakeit {

friend class WhenFunctor;

virtual ~StubbingChange() THROWS {
virtual ~StubbingChange() FAKEIT_THROWS {

if (UncaughtException()) {
return;
Expand Down
4 changes: 2 additions & 2 deletions include/fakeit/api_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
std::remove_reference<decltype((mock).get())>::type

#define OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<typename MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
fakeit::Prototype<prototype>::template MemberType<typename MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)

#define CONST_OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<typename MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)
fakeit::Prototype<prototype>::template MemberType<typename MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)

#define Dtor(mock) \
(mock).dtor().setMethodDetails(#mock,"destructor")
Expand Down
Loading

0 comments on commit 49b27fe

Please sign in to comment.