trompeloeil icon indicating copy to clipboard operation
trompeloeil copied to clipboard

Documentation: Clarify caveats of non-virtual function mocking

Open rcdailey opened this issue 6 years ago • 3 comments

The mocking non-virtual functions documentation in the Cook Book should have a disclaimer that if you upcast the concrete mock instance to a base type, those mock methods cannot be called. If the base class interface is not virtual, then no virtual dispatch will take place. Worth making it clear to folks that you aren't changing vftable behavior in your library; e.g. this isn't magical.

Thoughts?

rcdailey avatar May 02 '19 18:05 rcdailey

You are absolutely right. Trompeloeil works solely from the knowledge of the type, as it's visible at the site where you place expectations, so casting away from the known type will fail.

Feel free to issue a doc pull-request (directly to the master branch.)

rollbear avatar May 02 '19 18:05 rollbear

@rollbear I am working on that now, I just wanted to confirm with you before I contribute something. What maximum line length do you require in your markdown files? I typically hard wrap at 100th column, but yours seems much shorter than that.

rcdailey avatar May 03 '19 14:05 rcdailey

I don't have a hard limit, but I try not to go over 80. I'm sure you'll find counter examples, though.

rollbear avatar May 03 '19 15:05 rollbear