[openrtm-commit:01232] r2427 - branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests

openrtm @ openrtm.org openrtm @ openrtm.org
2014年 2月 9日 (日) 23:28:04 JST


Author: win-ei
Date: 2014-02-09 23:28:04 +0900 (Sun, 09 Feb 2014)
New Revision: 2427

Added:
   branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/TestRunner.cpp
Log:
Daily work.

Added: branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/TestRunner.cpp
===================================================================
--- branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/TestRunner.cpp	                        (rev 0)
+++ branches/work_ForDoil/OpenRTM-aist/src/lib/doil/utils/omniidl_be/tests/TestRunner.cpp	2014-02-09 14:28:04 UTC (rev 2427)
@@ -0,0 +1,125 @@
+// -*- C++ -*-
+/*!
+ * @file Run.cpp
+ * @brief CppUnit test runner
+ * @date $Date: 2007/12/20 07:50:17 $
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2006
+ *     Noriaki Ando
+ *     Task-intelligence Research Group,
+ *     Intelligent Systems Research Institute,
+ *     National Institute of
+ *         Advanced Industrial Science and Technology (AIST), Japan
+ *     All rights reserved.
+ *
+ * $Id: TestRunner.cpp 826 2008-08-26 08:13:39Z n-ando $
+ *
+ */
+
+/*
+ * $Log: TestRunner.cpp,v $
+ * Revision 1.1  2007/12/20 07:50:17  arafune
+ * *** empty log message ***
+ *
+ * Revision 1.1  2006/11/27 07:31:50  n-ando
+ * CppUnit tests runner.
+ *
+ */
+
+#include <stdlib.h>
+#include <string>
+#include <fstream>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/XmlOutputter.h>
+#include <cppunit/TextOutputter.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+enum FORMAT
+  {
+    TEXT_OUT,
+    XML_OUT,
+    COMPILER_OUT,
+  };
+
+int main(int argc, char* argv[])
+{
+
+  FORMAT format = TEXT_OUT;
+  int target = 0;
+  std::string xsl;
+  std::string ns;
+  std::string fname;
+  std::ofstream ofs;
+
+  int i(1);
+  while (i < argc)
+    {
+      std::string arg(argv[i]);
+      std::string next_arg;
+      if (i + 1 < argc) next_arg = argv[i + 1];
+      else              next_arg = "";
+
+      if (arg == "--text") { format = TEXT_OUT; break; }
+      if (arg == "--xml")
+	{
+	  if (next_arg == "")
+	    {
+	      fname = argv[0];
+	      fname += ".xml";
+	    }
+	  else
+	    {
+	      fname = next_arg;
+	    }
+	  format = XML_OUT;
+	  ofs.open(fname.c_str());
+	}
+      if ( arg == "--compiler"  ) { format = COMPILER_OUT; break; }
+      if ( arg == "--cerr"      ) { target = 1; break; }
+      if ( arg == "--xsl"       )
+	{
+	  if (next_arg == "") xsl = "default.xsl"; 
+	  else                xsl = next_arg;
+	}
+      if ( arg == "--namespace" )
+	{
+	  if (next_arg == "")
+	    {
+	      std::cerr << "no namespace specified" << std::endl;
+	      exit(1); 
+	    }
+	  else
+	    {
+	      xsl = next_arg;
+	    }
+	}
+      ++i;
+    }
+  CppUnit::TextUi::TestRunner runner;
+  if ( ns.empty() )
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+  else
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
+  CppUnit::Outputter* outputter = 0;
+  std::ostream* stream = target ? &std::cerr : &std::cout;
+  switch ( format )
+    {
+    case TEXT_OUT :
+      outputter = new CppUnit::TextOutputter(&runner.result(),*stream);
+      break;
+    case XML_OUT :
+      std::cout << "XML_OUT" << std::endl;
+      outputter = new CppUnit::XmlOutputter(&runner.result(),
+					    ofs, "shift_jis");
+      static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl);
+      break;
+    case COMPILER_OUT :
+      outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream);
+      break;
+    }
+  runner.setOutputter(outputter);
+  runner.run();
+  return 0; // runner.run() ? 0 : 1;
+}



More information about the openrtm-commit mailing list