Skip to content

Commit

Permalink
Merge 57e8521 into 01dc522
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Apr 16, 2023
2 parents 01dc522 + 57e8521 commit 29843a5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
8 changes: 5 additions & 3 deletions include/fakeit/FakeitExceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/
#pragma once

#include "fakeit/FakeitEvents.hpp"
#include <exception>

#include "mockutils/Macros.hpp"

#include "fakeit/FakeitEvents.hpp"

namespace fakeit {
#if __cplusplus >= 201703L || defined(__cpp_lib_uncaught_exceptions)
#if FAKEIT_CPLUSPLUS >= 201703L || defined(__cpp_lib_uncaught_exceptions)
inline bool UncaughtException () {
return std::uncaught_exceptions() >= 1;
}
Expand All @@ -36,7 +38,7 @@ namespace fakeit {
};


// Unlike verification exceptions (that are thrown from the test level), this exception
// Unlike verification exceptions (that are thrown from the test level), this exception
// should not inherit from std::exception so that production code will not catch it.
struct UnexpectedMethodCallException : public FakeitException {

Expand Down
14 changes: 7 additions & 7 deletions include/fakeit/StubbingProgress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace fakeit {
MethodStubbingProgress &operator=(const MethodStubbingProgress &other) = delete;

template<typename ... valuelist>
#if __cplusplus >= 201402L
#if FAKEIT_CPLUSPLUS >= 201402L
auto
#else
std::function<R (typename fakeit::test_arg<arglist>::type...)>
Expand All @@ -197,7 +197,7 @@ namespace fakeit {
}

template<typename ...T, int ...N>
#if __cplusplus >= 201402L
#if FAKEIT_CPLUSPLUS >= 201402L
auto
#else
std::function<R (typename fakeit::test_arg<arglist>::type...)>
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace fakeit {
MethodStubbingProgress &operator=(const MethodStubbingProgress &other) = delete;

template<typename ... valuelist>
#if __cplusplus >= 201402L
#if FAKEIT_CPLUSPLUS >= 201402L
auto
#else
std::function<void (typename fakeit::test_arg<arglist>::type...)>
Expand All @@ -340,7 +340,7 @@ namespace fakeit {
}

template<typename ...T, int ...N>
#if __cplusplus >= 201402L
#if FAKEIT_CPLUSPLUS >= 201402L
auto
#else
std::function<void (typename fakeit::test_arg<arglist>::type...)>
Expand Down Expand Up @@ -382,7 +382,7 @@ namespace fakeit {
template <typename ...T, int ...N>
static void CheckPositions(const std::tuple<ArgValue<T, N>...> arg_vals)
{
#if __cplusplus >= 201402L && !defined(_WIN32)
#if FAKEIT_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 @@ -434,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 && !defined (_WIN32)
#if FAKEIT_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 @@ -445,7 +445,7 @@ namespace fakeit {
ArgLocator<arg_index, check_index - 1>::AssignArg(std::forward<current_arg>(p), arg_vals);
}

#if __cplusplus < 201703L || defined (_WIN32)
#if FAKEIT_CPLUSPLUS < 201703L || defined (_WIN32)
private:
template<typename T, typename U>
static
Expand Down
14 changes: 10 additions & 4 deletions include/mockutils/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
#pragma once

#if defined (__GNUG__) || _MSC_VER >= 1900
#define FAKEIT_THROWS noexcept(false)
#define FAKEIT_NO_THROWS noexcept(true)
# define FAKEIT_THROWS noexcept(false)
# define FAKEIT_NO_THROWS noexcept(true)
#elif defined (_MSC_VER)
#define FAKEIT_THROWS throw(...)
#define FAKEIT_NO_THROWS
# define FAKEIT_THROWS throw(...)
# define FAKEIT_NO_THROWS
#endif

#ifdef _MSVC_LANG
# define FAKEIT_CPLUSPLUS _MSVC_LANG
#else
# define FAKEIT_CPLUSPLUS __cplusplus
#endif
4 changes: 3 additions & 1 deletion tests/cpp14_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* Created on Mar 10, 2014
*/

#if __cplusplus > 201103L
#include "mockutils/Macros.hpp"

#if FAKEIT_CPLUSPLUS > 201103L

#include <string>
#include "tpunit++.hpp"
Expand Down
5 changes: 3 additions & 2 deletions tests/stubbing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <string>
#include <queue>

#include "mockutils/Macros.hpp"

#include "tpunit++.hpp"
#include "fakeit.hpp"

Expand Down Expand Up @@ -236,7 +238,7 @@ struct BasicStubbing : tpunit::TestFixture {
i.procIncompatArgs(s, chk_v);
ASSERT_EQUAL(chk_v, v);

#if __cplusplus < 201703L
#if FAKEIT_CPLUSPLUS < 201703L || defined (_WIN32)
When(Method(mock, procIncompatArgs)).ReturnAndSet(_1 <= v);
try {
i.procIncompatArgs(s, chk_v);
Expand Down Expand Up @@ -884,4 +886,3 @@ struct BasicStubbing : tpunit::TestFixture {
}

} __BasicStubbing;

0 comments on commit 29843a5

Please sign in to comment.