Boost logo

Boost :

From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2006-02-03 03:37:44


Gennadiy Rozental wrote:
>> Anyway, you caught my attention. I checked the mock_object.hpp
>> header and also found a couple of usage examples under the
>> 'examples' directory. What I was missing though, was examples of
>> setting up / checking the expectations - did I just miss something
>> or aren't they there (yet)?
>
> Did you check logged_exp_example.cpp?

I've checked it and just now rechecked it. It looks like it requires an
input file of type .elog, right?

Couldn't find that one on my local harddrive so the test kept failing - is
there an option to generate this from a known good scenario, or what?

Are there any other methods for settings up the expectations
programmatically? Like (contrived pseudo-code example, never mind my cooking
;-):

namespace {

    struct KitchenRobotSuiteFixture
    {
        MockFridge f;
        MockStove s;
        MockTimer t;
    };

}

BOOST_FIXTURE_SUITE_BEGIN(KitchenRobotSuite, KitchenRobotSuiteFixture);

BOOST_AUTO_TEST_CASE(MakeHardBoiledEggs)
{
    const int Temperature = Stove::MaxTemp;
    const int NoOfEggs = 12;

    f.expect_call(Fridge::get_food, "eggs", NoOfEggs);
    s.expect_call(Stove::on, Temperature, Stove::WaitUntilReady);
    t.expect_call(Timer::wait, minutes(12) );
    s.expect_call(Stove::off);
    ... etc ...
    <somehow setup the combined call sequence>

    KitchenRobot kr(f, s, t);

    kr.MakeHardBoiledEggs(NoOfEggs);
}

BOOST_TEST_SUITE_END();

// Johan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk