Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-09-15 02:33:49


Hello,
I'm just writing some test and have so far the following code:

    vector<string> r = split_expression("1 + 1*2");
    char* expected[] = {"1", "+", "1", "*", "2"};

I'd like to compare the result with expectation, but I cannot write:

     BOOST_CHECK_EQUAL(r, vector<string>(expected, expected + 5));

because Boost.Test wants operator<< for vector<string>. I cannot write

     BOOST_CHECK_EQUAL_COLLECTIONS(r.begin(), r.end(), expected);

either, because if 'r' has more elements than expected, the test itself has
some chance of crashing. Of course, I can first compare sizes with
BOOST_REQUIRE, and then call BOOST_CHECK_EQUAL_COLLECTIONS,
but this solution is not so convenient.

In fact, I'm just about to use the above code to illustrance use of Boost.Test
to some folks, and I'm not sure I have any good explanation why the check
cannot be done in one step.

Is it possible to have some macro which accept two iterator ranges, as opposed
to one range and one iterator?

TIA,
Volodya

    


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