Git Product home page Git Product logo

Comments (5)

rollbear avatar rollbear commented on July 30, 2024 1

Experimental, and totally undocumented, support is now on the develop branch. For usage, lookup the file test/compiling_tests.hpp and search for the use of mock_interface<>. These are always marked override so there is no risk for accidentally mocking non-virtual functions. This implementation cannot handle overloads, but I'm not sure how much of a problem that is. It may not be very difficult to solve.

from trompeloeil.

rollbear avatar rollbear commented on July 30, 2024

I'll look into it. Looks cool. Whatever techniques it uses, though, are unlikely to be an easy fit into the current code in Trompeloeil.

How does it handle overloaded functions?

from trompeloeil.

ytimenkov avatar ytimenkov commented on July 30, 2024

As I understand from source code it passes pointer to the base member function to a trait template (which matches in compile time) which defines signature_t type which can be used to extract parameters' types later, with mocked function being declared as something like result_type<signature_t> mock_func(parameter_type<signature_t, 0> arg0, ...).

Of course this doesn't work when parameters are ambiguous, then one has to specify signature explicitly as 3rd parameter:

MOCK_BASE_CLASS( mock_class, base_class )
{
    MOCK_METHOD( method, 2, void( int, const std::string& ), identifier_1 ) // both the signature and identifier must be specified because of ambiguity due to overloading
    MOCK_METHOD( method, 1, void( float ), identifier_2 )                   // the identifier must differ from the previous one in order to fully disambiguate methods
};

from trompeloeil.

rollbear avatar rollbear commented on July 30, 2024

I ran some simple experiments, and superficially it looks quite simple to do. I'm sure I'll stumble onto some gotcha, though.

It'll probably take a while, though, since there are some other things that I really needs my attention.

from trompeloeil.

rollbear avatar rollbear commented on July 30, 2024

Functionality now in tagged release v30

from trompeloeil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.