22 #include <cppunit/ui/text/TestRunner.h> 23 #include <cppunit/TextOutputter.h> 24 #include <cppunit/extensions/TestFactoryRegistry.h> 25 #include <cppunit/extensions/HelperMacros.h> 26 #include <cppunit/TestAssert.h> 39 :
public CppUnit::TestFixture
58 m_pORB = CORBA::ORB_init(argc, argv);
59 m_pPOA = PortableServer::POA::_narrow(
60 m_pORB->resolve_initial_references(
"RootPOA"));
61 m_pPOA->the_POAManager()->activate();
92 std::string name =
"name of execution context";
94 std::auto_ptr<RTC::ECFactoryBase> factory(
97 RTC::ECCreate<RTC::PeriodicExecutionContext>,
98 RTC::ECDelete<RTC::PeriodicExecutionContext>));
101 CPPUNIT_ASSERT_EQUAL(name, std::string(factory->name()));
112 std::auto_ptr<RTC::ECFactoryBase> factory(
114 "name of execution context",
115 RTC::ECCreate<RTC::PeriodicExecutionContext>,
116 RTC::ECDelete<RTC::PeriodicExecutionContext>));
120 CPPUNIT_ASSERT(dynamic_cast<RTC::PeriodicExecutionContext*>(ec) != 0);
123 m_pPOA->deactivate_object(*m_pPOA->servant_to_id(ec));
124 factory->destroy(ec);
125 CPPUNIT_ASSERT(dynamic_cast<RTC::PeriodicExecutionContext*>(ec) == 0);
137 int main(
int argc,
char* argv[])
150 std::string arg(argv[i]);
151 std::string next_arg;
152 if (i + 1 < argc) next_arg = argv[i + 1];
155 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
168 ofs.open(fname.c_str());
170 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
171 if ( arg ==
"--cerr" ) { target = 1;
break; }
172 if ( arg ==
"--xsl" )
174 if (next_arg ==
"") xsl =
"default.xsl";
177 if ( arg ==
"--namespace" )
181 std::cerr <<
"no namespace specified" << std::endl;
191 CppUnit::TextUi::TestRunner runner;
193 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
195 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
196 CppUnit::Outputter* outputter = 0;
197 std::ostream* stream = target ? &std::cerr : &std::cout;
201 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
204 std::cout <<
"XML_OUT" << std::endl;
205 outputter =
new CppUnit::XmlOutputter(&runner.result(),
207 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
210 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
213 runner.setOutputter(outputter);
218 #endif // ECFactory_cpp
int main(int argc, char **argv)
virtual ~ECFactoryTests()
Destructor.
A base class for ExecutionContext.
virtual void tearDown()
Test finalization.
PortableServer::POA_ptr m_pPOA
void test_name()
name()メソッドのテスト
CPPUNIT_TEST_SUITE(ECFactoryTests)
ExtTrigExecutionContext class.
void test_create_and_destroy()
create()メソッドとdestroy()メソッドのテスト
CPPUNIT_TEST_SUITE_REGISTRATION(ECFactory::ECFactoryTests)
virtual void setUp()
Test initialization.
ExecutionContext Factory class.
PeriodicExecutionContext class.
ECFactoryTests()
Constructor.