50 makefile_am =
"""# -*- Makefile -*- 51 #------------------------------------------------------------ 53 # @brief Makefile.am for [class_name] unit test 54 # @date [dollar]Date[dollar] 56 # @author Noriaki Ando <n-ando@aist.go.jp> 61 #------------------------------------------------------------ 69 AUTOMAKE_OPTIONS = 1.9 79 noinst_PROGRAMS = [class_name]Tests 81 [class_name]Tests_SOURCES = ../TestRunner.cpp [class_name]Tests.cpp 82 [class_name]Tests_LDFLAGS = -L$(libdir) 83 [class_name]Tests_LDADD = -lcppunit 85 TEST_SRC = [dollar]([class_name]Tests_SOURCES) 97 rm -f *.o *.Po *.gch *.la 104 #------------------------------------------------------------ 105 # vcproj file build rules 106 #------------------------------------------------------------ 109 vcproj: [class_name]_vc8.vcproj [class_name]_vc9.vcproj 111 [class_name]_vc8.vcproj: 112 $(top_builddir)/build/vcprojtool.py vcproj \\ 113 --projectname [class_name]Test \\ 115 --vcversion "8.00" \\ 116 --version $(COIL_VERSION) \\ 117 --out $(win32_builddir)/[class_name]_vc8.vcproj \\ 118 --yaml ../coil_test.vcproj.yaml \\ 121 qkc -sm $(win32_builddir)/[class_name]_vc8.vcproj 123 [class_name]_vc9.vcproj: 124 $(top_builddir)/build/vcprojtool.py vcproj \\ 125 --projectname [class_name]Test \\ 127 --vcversion "9.00" \\ 128 --version $(COIL_VERSION) \\ 129 --out $(win32_builddir)/[class_name]_vc9.vcproj \\ 130 --yaml ../coil_test.vcproj.yaml \\ 133 qkc -sm $(win32_builddir)/[class_name]_vc9.vcproj 138 test_cpp =
"""// -*- C++ -*- 140 * @file [class_name]Tests.cpp 141 * @brief [class_name] test class 142 * @date [dollar]Date[dollar] 144 * @author Noriaki Ando <n-ando@aist.go.jp> 152 * [dollar]Log[dollar] 157 #ifndef [class_name]_cpp 158 #define [class_name]_cpp 160 #include <cppunit/ui/text/TestRunner.h> 161 #include <cppunit/TextOutputter.h> 162 #include <cppunit/extensions/TestFactoryRegistry.h> 163 #include <cppunit/extensions/HelperMacros.h> 164 #include <cppunit/TestAssert.h> 167 * @class [class_name]Tests class 168 * @brief [class_name] test 170 namespace [class_name] 173 class [class_name]Tests 174 : public CppUnit::TestFixture 176 CPPUNIT_TEST_SUITE([class_name]Tests); 177 CPPUNIT_TEST(test_case0); 178 CPPUNIT_TEST_SUITE_END(); 199 * @brief Test initialization 206 * @brief Test finalization 208 virtual void tearDown() 217 }; // namespace [class_name] 221 * Register test suite 223 CPPUNIT_TEST_SUITE_REGISTRATION([class_name]::[class_name]Tests); 226 int main(int argc, char* argv[]) 228 CppUnit::TextUi::TestRunner runner; 229 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); 230 CppUnit::Outputter* outputter = 231 new CppUnit::TextOutputter(&runner.result(), std::cout); 232 runner.setOutputter(outputter); 233 bool retcode = runner.run(); 237 #endif // [class_name]_cpp 244 self.
data[
"dollar"] =
"$" 245 self.
data[
"class_name"] = classname
246 self.
data[
"makefile"] = classname +
"/Makefile.am" 247 self.
data[
"testcpp"] = classname +
"/" + classname +
"Tests.cpp" 258 def gen(self, fname, temp_txt, data):
262 text=t.generate(data)
265 print "\"", fname,
"\"" " was generated." 274 self.
gen(self.
data[
"makefile"], makefile_am, self.
data)
278 self.
gen(self.
data[
"testcpp"], test_cpp, self.
data)
282 if len(sys.argv) < 2:
285 class_name = sys.argv[1]
287 os.mkdir(class_name, 0755)
289 print "Directory \"" + class_name +
"\" already exists."
def gen(self, fname, temp_txt, data)
def __init__(self, classname)