|
Boost : |
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2006-09-13 15:45:18
Hi Maciej,
On 9/14/06, Maciej Sobczak <prog_at_[hidden]> wrote:
>
> What's the added value of the above when compared to:
>
> value_should_equal(my_value, 10);
> value_should_not_equal(my_value, 9);
> pointer_should_be_null(my_pointer);
> pointer_should_not_be_null(my_pointer);
>
> or maybe:
>
> should_equal(my_value, 10);
> should_not_equal(my_value, 9);
> should_be_null(my_pointer);
> should_not_be_null(my_pointer);
>
The added value I suppose would be the ability to store the spec<>
objects and even extend the specifications later. Consider having the
ability to wrap the spec<> object and decorating it to do something
else later -- specially making it more type-safe, and more intuitive
to use.
The problem with the above examples are that you need to remember
which one is the value being tested, and which one is the expected
result. Having something like
value(a).should.equal(10);
or perhaps:
spec<int> return_value = value(a);
// ...
return_value.should.be_less_than(10);
return_value.should.be_more_than(5);
vector<std::string> my_vector;
// ...
container(my_vector).should.contain("my_type");
container(my_vector).should.have_size(10);
If the spec<> type derived from a parametric base class dependent on
the parameter to spec, perhaps other specifications can be defined and
added later.
The design of the library will greatly benefit in terms of
flexibility, without having to get stuck with just plain methods that
might be too hard to extend.
HTH...
-- Dean Michael C. Berris C++ Software Architect Orange and Bronze Software Labs, Ltd. Co. web: http://software.orangeandbronze.com/ email: dean_at_[hidden] mobile: +63 928 7291459 phone: +63 2 8943415 other: +1 408 4049532 blogs: http://mikhailberis.blogspot.com http://3w-agility.blogspot.com http://cplusplus-soup.blogspot.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk