I'm currently writing a test program who test each of the auto_ptr class functions. I have some problem to find a way to test certain functions :
- the copy constructor for another type of auto_ptr ?
- the operator -> ?
- the operator = from another type of auto_ptr ?
- the test conversion function (template <typename Y> operator auto_ptr<Y>() throw();)?
the copy constructor for another type of auto_ptr ?
I don't know what you mean by "another type of auto_ptr". If you mean you want to test the copy constructor of auto_ptr? In that case you can test so that the new auto_ptr object created with the copy constructor points to the object and that the old auto_ptr no longer points to anything.
the operator -> ?
You could test that (*p).foo do the same as p->foo
the operator = from another type of auto_ptr ?
This is very similar to the copy constructor so the test will probably be very similar too.
the test conversion function (template <typename Y> operator auto_ptr<Y>() throw();)?
I think this is so that you can convert a auto_ptr<X> to a auto_ptr<Y> where Y is a superclass of X.
I figured out for the first 3 functions thank you.
But the last one, the conversion function, I don't find a way to test it, for the moment I find on internet a test like this (A is a base class and B a derived class) :