Cevelop / cevelop

The C++ IDE for professional developers
Eclipse Public License 2.0
6 stars 0 forks source link

Mockater uses namespace prefix for local allCalls instance. #11

Open PeterSommerlad opened 7 years ago

PeterSommerlad commented 7 years ago

Expected Behavior

Generated Mock Object support code should refer to the correct variable and compile code. May be a port to C++11/14 of the header and the generated code should be done. The generated code assumes availability of boost/assign.hpp which is not available in C++1x setting. (adaptation already done in example code below)

Actual Behavior

when adding mocking support to a local template argument class a checking ASSERT_EQUAL is added that will not compile:

void OrderFillFromWarehouse(){
    INIT_MOCKATOR();
    static std::vector<calls> allCalls(1);
    struct MockWarehouse {
        size_t const mock_id;

        MockWarehouse()
        :mock_id(reserveNextCallId(allCalls))
        {
            allCalls[mock_id].push_back(call("MockWarehouse()"));
        }

        bool hasInventory(std::string const & what, int const & howmany) const {
            allCalls[mock_id].push_back(call("hasInventory(const std::string&, const int&) const", what, howmany));
            return bool();
        }

        void remove(std::string const & what, int const & howmany) const {
            allCalls[mock_id].push_back(call("remove(const std::string&, const int&) const", what, howmany));
        }
    };
    MockWarehouse warehouse { };
    OrderT<MockWarehouse> order(TALISKER,50);
    order.fill(warehouse);
    ASSERT(not order.isFilled());
    calls expectedMockWarehouse{
        call("MockWarehouse()"),
        call("hasInventory(const std::string&, const int&) const", std::string(), int()),
        call("remove(const std::string&, const int&) const", std::string(), int())
    };
    ASSERT_EQUAL(expectedMockWarehouse, CT::allCalls[1]);//CT:: is wrong here
}

Cevelop Version, Operating System and Compiler

The more we know about your setup, the easier it will be for us to reproduce the problem.