Skip to content

Commit

Permalink
includes: Update Trompeloeil to v49
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Oct 7, 2024
1 parent acf96e2 commit 640867e
Show file tree
Hide file tree
Showing 5 changed files with 1,274 additions and 123 deletions.
7 changes: 7 additions & 0 deletions inc/trompeloeil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@
#include "trompeloeil/matcher/any.hpp"
#include "trompeloeil/matcher/compare.hpp"
#include "trompeloeil/matcher/deref.hpp"
#if TROMPELOEIL_CPLUSPLUS >= 201402L
#include "trompeloeil/matcher/member_is.hpp"
#endif
#include "trompeloeil/matcher/not.hpp"
#if TROMPELOEIL_CPLUSPLUS >= 201402L
#include "trompeloeil/matcher/range.hpp"
#endif
#include "trompeloeil/matcher/re.hpp"
#include "trompeloeil/matcher/set_predicate.hpp"
#include "trompeloeil/sequence.hpp"
#include "trompeloeil/stream_tracer.hpp"
#ifdef __cpp_impl_coroutine
Expand Down
61 changes: 61 additions & 0 deletions inc/trompeloeil/matcher/member_is.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Trompeloeil C++ mocking framework
*
* Copyright (C) Björn Fahller
* Copyright (C) Andrew Paxie
*
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy atl
* http://www.boost.org/LICENSE_1_0.txt)
*
* Project home: https://github.com/rollbear/trompeloeil
*/

#ifndef TROMPELOEIL_MEMBER_IS_HPP
#define TROMPELOEIL_MEMBER_IS_HPP

#ifndef TROMPELOEIL_MATCHER_HPP
#include "../matcher.hpp"
#endif

namespace trompeloeil
{

namespace impl {
template <typename M>
struct member_is_matcher
{
template <typename V, typename C>
bool operator()(const V& v, const C& c) const
{
return trompeloeil::param_matches(c, std::ref(m(v)));
}
M m;
};
}

template <typename M, typename C>
auto match_member_is(M m, const char* name, C&& c)
{
return trompeloeil::make_matcher<trompeloeil::wildcard>(
impl::member_is_matcher<M>{m},
[name](std::ostream& os, const C& compare) {
os << ' ' << name << compare;
},
std::forward<C>(c)
);
}
}

#define TROMPELOEIL_MEMBER_IS(member_name, compare) \
trompeloeil::match_member_is( \
std::mem_fn(member_name), \
#member_name, \
compare)

#ifndef TROMPELOEIL_LONG_MACROS
#define MEMBER_IS TROMPELOEIL_MEMBER_IS
#endif

#endif // TROMPELOEIL_MEMBER_IS_HPP
Loading

0 comments on commit 640867e

Please sign in to comment.