AnimatLab  2
Test
ClassFactory_Tests.cpp
1 #include "stdafx.h"
2 #include <boost/test/unit_test.hpp>
3 #include <boost/shared_ptr.hpp>
4 
5 BOOST_AUTO_TEST_SUITE( ClassFactory_Suite )
6 
7 bool is_critical( CStdErrorInfo const& ex ) { return ex.m_lError < 0; }
8 
9 BOOST_AUTO_TEST_CASE( CreateClassFactory )
10 {
11  //boost::shared_ptr<IStdClassFactory> lpFactory(IStdClassFactory::LoadModule("StdClassFactoryTester.dll"));
12  boost::shared_ptr<IStdClassFactory> lpFactory(IStdClassFactory::LoadModule("BulletAnimatSim_vc10D.dll"));
13 
14  BOOST_CHECK( lpFactory != NULL );
15 
16  CStdSerialize *lpTest = NULL;
17  BOOST_CHECK_EXCEPTION( lpTest = lpFactory->CreateObject("test1", "TestObject"), CStdErrorInfo, is_critical );
18  BOOST_CHECK_EXCEPTION( lpTest = lpFactory->CreateObject("test", "TestObject1"), CStdErrorInfo, is_critical );
19 
20  boost::shared_ptr<CStdSerialize> lpTest2(lpFactory->CreateObject("test", "TestObject"));
21  BOOST_CHECK( lpTest2 != NULL );
22 
23  CStdSerialize *lpClone = lpTest2->Clone();
24  BOOST_CHECK( lpClone == NULL );
25 }
26 
27 BOOST_AUTO_TEST_SUITE_END()