src/core/test.cc
changeset 4531 14a102415139
parent 2834 1aab57845b07
--- a/src/core/test.cc	Fri Jun 12 12:33:21 2009 +0100
+++ b/src/core/test.cc	Fri Jun 12 12:33:37 2009 +0100
@@ -55,6 +55,18 @@
 {
   Get ()->m_verbose = true;
 }
+
+void
+TestManager::PrintTestNames (std::ostream &os)
+{
+  for (TestsCI i = Get ()->m_tests.begin (); i != Get ()->m_tests.end (); i++) 
+    {
+      std::string *testName = (*i).second;
+      os << *testName << std::endl;
+    }
+}
+
+
 std::ostream &
 TestManager::Failure (void)
 {
@@ -95,6 +107,47 @@
   return isSuccess;
 }
 
+bool 
+TestManager::RunTest (std::string name)
+{
+  return Get ()->RealRunTest (name);
+}
+bool 
+TestManager::RealRunTest (std::string name)
+{
+  TestsCI i;
+  
+  for (i = m_tests.begin (); i != m_tests.end (); i++) 
+    {
+      std::string *testName = (*i).second;
+      if (*testName == name) 
+        {
+          break;
+        }
+    }
+  if (i == m_tests.end ())
+    {
+      std::cerr << "Test with name " << name << " not found." << std::endl;
+    }
+  
+  if (!(*i).first->RunTests ()) 
+    {
+      if (m_verbose) 
+        {
+          std::cerr << "FAIL " << name << std::endl;
+        }
+      return false;
+    } 
+  else 
+    {
+      if (m_verbose) 
+        {
+          std::cerr << "PASS "<< name << std::endl;
+        }
+      return true;
+    }
+}
+
 Test::Test (char const *name)
 {
   TestManager::Add (this, name);