From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-12-21 10:09:10
I'm using the Unit Test Framework for testing my own code.
I've found that you can add a test case being a class member function:
void foo() ;
test->add( BOOST_TEST_CASE( &A::foo) );
First, when I saw this sort of example in the documentation, I figured that
there was a mistake, and that
foo() is a static method, because there isn't any instance of A created (as
shown by the example)
Then I realize, that actually, the test case internally creates a 'new'
A::A() by itself.
This should be properly documented.
Second: in my particular case, I NEED to test A::foo() but upon a properly
constructed A instance.
It makes no sense at all to test A::foo() on a default constructed A.
That is, I need something like:
A ( ... ) ;
void foo() ;
test->add( BOOST_TEST_CASE( make_closure(a, &A::foo) ) );
Adding this functionality to unit_test_suite.hpp wouldn't be so difficult,
but I encountered a problem:
What's the rational of test_case::init()/destroy().
It *creates* and *destroys* test cases (in this cases 'A's) on behalf of the
In the example case above, if the test_suite() destroys 'a' and then creates
another 'A'by default, the 'foo' method being tested will behave
So, is the automatic init()/destroy() scheme really needed? What's its
Is there any (other) way to test a method associated with a given class
*instance*?, or it can only test (conceptually static) class methods.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk