Made ITestCase a shared object

This commit is contained in:
Phil Nash 2012-08-14 08:38:22 +01:00
parent a67d833091
commit 9c6ce97f01
6 changed files with 19 additions and 79 deletions

View file

@ -68,31 +68,18 @@ namespace Catch {
///////////////////////////////////////////////////////////////////////////
class FreeFunctionTestCase : public ITestCase {
class FreeFunctionTestCase : public SharedImpl<ITestCase> {
public:
FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
virtual ~FreeFunctionTestCase();
virtual void invoke() const {
m_fun();
}
virtual ITestCase* clone() const {
return new FreeFunctionTestCase( m_fun );
}
virtual bool operator == ( const ITestCase& other ) const {
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && m_fun == ffOther->m_fun;
}
virtual bool operator < ( const ITestCase& other ) const {
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && m_fun < ffOther->m_fun;
}
private:
virtual ~FreeFunctionTestCase();
TestFunction m_fun;
};