Check design of cpp::dynamic_reflection::Object tests
Opened this issue · 0 comments
This tests mock the 5 special member functions of a class (default ctor,
copy ctor, copy assignment operator, etc) to check whether they are called
or not during different operations of the Object
wrapper. The mocks get
pointers to the objects involved in the special member function invocation
to also check if the call was done in the right object.
The problem with this approach is that the mocks call expectations may
fail depending on the behavior of the allocator being used by Type
class
(Currently std::free()
). The naive approach of comparing pointers to
objects to check for their identity could (and it does) fail if for
whatever reason the allocator returns the same address an
already-deallocated tested object had. Which is kind of ironic since
that behavior is a sign the allocator is performing well, improving cache
locallity.
In that case, the mock call expectation on a special function would fail,
since these expectectations are set to be called once per tested object
(which is the default behavior of GMock's EXPECT_CALL()
).
That said, I didn't find a better alternative for this tests...