19 #ifndef NumberingPolicy_cpp 20 #define NumberingPolicy_cpp 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> 33 :
public CppUnit::TestFixture
80 std::string object1 =
"apple";
81 std::string object2 =
"orange";
82 std::string object3 =
"banana";
87 CPPUNIT_ASSERT_EQUAL(std::string(
"0"), policy->onCreate(&object1));
88 CPPUNIT_ASSERT_EQUAL(std::string(
"1"), policy->onCreate(&object2));
89 CPPUNIT_ASSERT_EQUAL(std::string(
"2"), policy->onCreate(&object3));
92 policy->onDelete(&object1);
93 policy->onDelete(&object2);
97 CPPUNIT_ASSERT_EQUAL(std::string(
"0"), policy->onCreate(&object2));
98 CPPUNIT_ASSERT_EQUAL(std::string(
"1"), policy->onCreate(&object1));
110 int main(
int argc,
char* argv[])
123 std::string arg(argv[i]);
124 std::string next_arg;
125 if (i + 1 < argc) next_arg = argv[i + 1];
128 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
141 ofs.open(fname.c_str());
143 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
144 if ( arg ==
"--cerr" ) { target = 1;
break; }
145 if ( arg ==
"--xsl" )
147 if (next_arg ==
"") xsl =
"default.xsl";
150 if ( arg ==
"--namespace" )
154 std::cerr <<
"no namespace specified" << std::endl;
164 CppUnit::TextUi::TestRunner runner;
166 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
168 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
169 CppUnit::Outputter* outputter = 0;
170 std::ostream* stream = target ? &std::cerr : &std::cout;
174 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
177 std::cout <<
"XML_OUT" << std::endl;
178 outputter =
new CppUnit::XmlOutputter(&runner.result(),
180 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
183 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
186 runner.setOutputter(outputter);
191 #endif // NumberingPolicy_cpp int main(int argc, char **argv)
virtual void setUp()
Test initialization.
void test_onCreate_and_onDelete()
DefaultNumberingPolicy::onCreate()とDefaultNumberingPolicy::onDelete()のテスト
CPPUNIT_TEST_SUITE(NumberingPolicyTests)
CPPUNIT_TEST(test_onCreate_and_onDelete)
Object numbering policy class.
CPPUNIT_TEST_SUITE_REGISTRATION(Tests::NumberingPolicyTests)
~NumberingPolicyTests()
Destructor.
Class for naming policy management when creating objects.
NumberingPolicyTests()
Constructor.
virtual void tearDown()
Test finalization.