Releases: rollbear/trompeloeil
v19
-
Fixed obscure bug when placing an expectation using a value implicitly
convertible to the target type, but not equal comparable with it.Example:
struct S { S(const char* s_) : s(s_) {} bool operator(const char*) = delete; bool operator==(const S& rh) const { return s == rh.s; } std::string s; }; struct mock { MAKE_MOCK1(func, void(S)); }; TEST(...) { mock m; REQUIRE_CALL(m, func("string")); // now compiles and compares the function call parameter value // with S("string") }
-
Improved compilation error messages for type-mismatch situations in
.RETURN()
v18
-
Writing custom matchers is much simplified through the use
of function templatemake_matcher<>()
, which accepts lambdas
for predicate and printing error message.The old technique of inheriting from
trompeloeil::matcher
ortrompeloeil::typed_matcher<T>
still works.See CookBook for details.
-
Further internal restructuring for yet reduced test program build time.
v17
v16
-
.IN_SEQUENCE(...)
can now be used withREQUIRE_DESTRUCTION(...)
andNAMED_REQUIRE_DESTRUCTION(...)
to ensure objects are destroyed in the intended order.
Example:auto p1 = new trompeloeil::deathwatched<mock1>; auto p2 = new trompeloeil::deathwatched<mock2>; trompeloeil::sequence s; REQUIRE_DESTRUCTION(*p1) .IN_SEQUENCE(s); REQUIRE_DESTRUCTION(*p2) .IN_SEQUENCE(s); call_destroyer(p1, p2); // both must be destroyed, p1 before p2.
-
class
trompeloeil::lifetime_monitor
now inherits from classtrompeloeil::expectation
, so usingstd::unique_ptr<expectation> p = NAMED_REQUIRE_DESTRUCTION(obj);
instead of
std::unique_ptr<lifetime_monitor> p = NAMED_REQUIRE_DESTRUCTION(obj);
works equally well, reduces the cognitive load a bit, and seems to build slightly faster.
v15
v14
-
Fixed bug when the destruction of a sequence object with still
living expectations caused call toabort()
. -
You can now add extra trailing specifiers to a mock function,
such as theoverride
context sensitive specifier, and/or the
keywordnoexcept
(careful with the latter if your registered
reporter can/does throw.)Example:
struct D : public B { MAKE_MOCK1(func, int(int), override); };
v13
- Mock functions and their expectations are thread safe, using a global recursive mutex
- Silenced warnings from g++ -Wshadow.
v12
- Built in matchers are duck tuped by default, i.e.
eq
,ne
,gt
,ge
,
lt
,le
do by default match any parameter that supports operators
==
,!=
,>
,>=
,<
,<=
with the value provided. If needed for
disambiguation of overloads an explicit type can be provided. In the
example below the expectation onnumfunc
will match a function
numfunc
with any parameter type that can be compared as > 3.
The expectation onstrfunc
will only match an overload with
std::string&
(if there are competing overloads, e.g.
strfunc(const char*)
andstrfunc(const std::string)
.)
REQUIRE_CALL(obj, numfunc(gt(3)));
REQUIRE_CALL(obj, strfunc(eq<std::string&>("foo")));
- Fixed a bug with return type deduction where an array type expression
was used. E.g. returning a string literal when the return type was
const char*
orstd::string
caused a compilation error. - Fixed a bug when the
eq(nullptr)
matcher actually checked if!=
comparison withnullptr
was allowed. - Reluctantly reverted use of
std::tuple_element_t<>
for
typename tuppe_element<>::type
, to support g++ 4.9.0 (4.9.1 does have
std::tuple_element_t<>
.)
v11
-
Added regular expression matcher for std::string and c-strings
-
Added specialization eq for pointer-like parameters and pointer-to-member parameters. This is mostly useful for pointer to pointer parameters, e.g.:
REQUIRE_CALL(obj, func(*trompeloeil::eq(nullptr)));
-
Improved accuracy of compilation error message when attempting to place expectation that does not uniquely match any function signature.
v10
- Fixed bug when wildcard
_
could not matchstd::ostream&
- Fixed ADL bugs
- Added functionality to use the dereference operator (prefix operator*) on any matcher to instead match a pointer to the value to check.
- Documented adapter for VisualStudio MSTest
- Corrected documentation bug for how to write report formatting function
trompeloeil::print<>(std::ostream&, T const&)
.