41 #include <cppunit/ui/text/TestRunner.h> 42 #include <cppunit/TextOutputter.h> 43 #include <cppunit/extensions/TestFactoryRegistry.h> 44 #include <cppunit/extensions/HelperMacros.h> 45 #include <cppunit/TestAssert.h> 50 #include <coil/Properties.h> 58 void log(
const std::string& msg)
66 for (
int i = 0; i < (int)
m_log.size(); ++i)
68 if (
m_log[i] == line) ++count;
82 :
RTC::RTObject_impl(orb, poa), m_logger(NULL)
96 void log(
const std::string& msg)
98 if (m_logger != NULL) m_logger->
log(msg);
104 CORBA::ORB_ptr orb = manager->
getORB();
105 PortableServer::POA_ptr poa = manager->
getPOA();
111 if (rtc != NULL) rtc->_remove_ref();
115 :
public CppUnit::TestFixture
118 CPPUNIT_TEST(test_create_and_destroy);
119 CPPUNIT_TEST(test_profile);
120 CPPUNIT_TEST(test_number);
121 CPPUNIT_TEST_SUITE_END();
174 CPPUNIT_ASSERT(rtc != NULL);
177 CPPUNIT_ASSERT(mock != NULL);
184 CPPUNIT_ASSERT_EQUAL(std::string(
"NAME"), propertiesRet.
getProperty(
"name"));
205 CPPUNIT_ASSERT_EQUAL(std::string(
"NAME"), propertiesRet.
getProperty(
"name"));
224 std::vector<RTC::RtcBase*> rtcList;
225 for (
int i = 0; i < MAX_NUM; ++i)
228 CPPUNIT_ASSERT_EQUAL(i-1, factory.
number());
232 CPPUNIT_ASSERT(rtc != NULL);
235 CPPUNIT_ASSERT_EQUAL(i, factory.
number());
237 rtcList.push_back(rtc);
240 for (
int i = 0; i < MAX_NUM; ++i)
243 CPPUNIT_ASSERT_EQUAL(i, factory.
number());
252 CPPUNIT_ASSERT_EQUAL(i-1, factory.
number());
266 int main(
int argc,
char* argv[])
279 std::string arg(argv[i]);
280 std::string next_arg;
281 if (i + 1 < argc) next_arg = argv[i + 1];
284 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
297 ofs.open(fname.c_str());
299 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
300 if ( arg ==
"--cerr" ) { target = 1;
break; }
301 if ( arg ==
"--xsl" )
303 if (next_arg ==
"") xsl =
"default.xsl";
306 if ( arg ==
"--namespace" )
310 std::cerr <<
"no namespace specified" << std::endl;
320 CppUnit::TextUi::TestRunner runner;
322 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
324 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
325 CppUnit::Outputter* outputter = 0;
326 std::ostream* stream = target ? &std::cerr : &std::cout;
330 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
333 std::cout <<
"XML_OUT" << std::endl;
334 outputter =
new CppUnit::XmlOutputter(&runner.result(),
336 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
339 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
342 runner.setOutputter(outputter);
347 #endif // Factory_cpp
int main(int argc, char **argv)
virtual coil::Properties & profile()
Get the component profile.
PortableServer::POA_ptr getPOA()
Get a pointer to RootPOA held by Manager.
void log(const std::string &msg)
virtual int number()
Get the number of current instances.
~FactoryTests()
Destructor.
std::vector< std::string > m_log
CORBA::ORB_ptr getORB()
Get the pointer to ORB.
coil::Properties & getProperties()
[local interface] Get RTC property
RTComponent manager class.
void DeleteRTObjectMock(RTC::RtcBase *rtc)
void test_create_and_destroy()
create()メソッドとdestroy()メソッドのテスト
RTObjectMock(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa)
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
static Manager * init(int argc, char **argv)
Initialize manager.
std::string setProperty(const std::string &key, const std::string &value)
Set a value associated with key in the property list.
void test_profile()
profile()メソッドのテスト
int countLog(const std::string &line)
CPPUNIT_TEST_SUITE_REGISTRATION(Tests::FactoryTests)
Class represents a set of properties.
void test_number()
number()メソッドのテスト
::OutPortBase::Logger logger
virtual RTObject_impl * create(Manager *mgr)
Create RT-Components.
void setLogger(Logger *logger)
FactoryTests()
Constructor.
virtual void destroy(RTObject_impl *comp)
Destroy RT-Components.
RTC::RtcBase * CreateRTObjectMock(RTC::Manager *manager)
virtual void setUp()
Test initialization.
virtual void tearDown()
Test finalization.
void log(const std::string &msg)