Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2006-09-13 14:54:19


Hi Everyone,

I've been mulling around having watched this video (
http://tinyurl.com/kywhy ) about Behavior Driven Development (
http://tinyurl.com/jzbcb ). I've been practicing TDD for a while now,
and it (BDD) seems like a more "intuitive" and readable alternative to
the "assert*" way of specifying behavior.

I was on the way to writing something quick to use in a project
in-house, and thought out loud: would the Boost community be
interested in having something like this alongside or built upon the
already existing testing framework?

I had been thinking about the syntax to which the BDD approach allows us:

int my_value = 0;
//...
value(my_value).should.equal(10); // will throw an exception
value(my_value).should.not_equal(9); // will also throw an exception

char * my_pointer = NULL;
//...
pointer(my_pointer).should.be_null(); // will evaluate to true, or do nothing
pointer(my_pointer).should.not_be_null(); // will throw an exception

where value(my_value) is defined as (untested):

template <typename T>
spec<T> value ( const T & v ) {
  return spec<T>(v);
};

where spec<> is defined as (untested):

template <typename T>
struct spec {
  T value;
  should_impl<T> should(value);
};

and should_impl<> is defined as (untested):

template <typename T>
struct should_impl {
  T & _value;
  should_impl(T & value) : _value(value);

  template <typename ArgType>
  bool equal (const ArgType & expected) const {
    if (_value == expected)
      return true;
    throw not_equal_exception<T, ArgType>(_value, expected);
  };

  template <typename ArgType>
  bool not_equal (const ArgType & expected) const {
    if (_value != expected)
      return true;
    throw are_equal_exception<T, ArgType> (_value, expected);
  };

};

Which would entail the use of some of the Boost.MPL for some of the
type-safeness magic required to determine if the value being
scrutinized (i don't want to say tested) is a pointer, a reference, or
an instance among other things.

I'm writing this message off the top of my head and even before I
start writing the framework for an internal project; so I'd like to
know if anybody is interested in something like this.

(After all, I'd like to know if there is enough interest so that I can
write it from scratch to comply with the Boost Library requirements in
mind already). ;)

Have a great day everyone, and hope to hear from you soon!

-- 
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