]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/test.cpp
variadic macros need specializations for both wxCharBuffer and wxScopedCharBuffer...
[wxWidgets.git] / tests / test.cpp
index fa9ec1e6a44f501967195518c1fd28e008833756..54f56612f62b56ea5c5aac52e6da93b6bf6ebe2f 100644 (file)
@@ -108,7 +108,7 @@ public:
         {
             return functor();
         }
-        catch ( std::exception& )
+        catch ( std::exception& )
         {
             // cppunit deals with the standard exceptions itself, let it do as
             // it output more details (especially for std::exception-derived
@@ -143,7 +143,8 @@ public:
         m_watch.Start();
     }
 
-    virtual void addFailure(const CppUnit::TestFailure& failure) {
+    virtual void addFailure(const CppUnit::TestFailure& failure)
+    {
         m_result = failure.isError() ? RESULT_ERROR : RESULT_FAIL;
     }
 
@@ -157,21 +158,27 @@ public:
     }
 
 protected :
-    enum ResultType {
+    enum ResultType
+    {
         RESULT_OK = 0,
         RESULT_FAIL,
-        RESULT_ERROR
+        RESULT_ERROR,
+        RESULT_MAX
     };
 
-    wxString GetResultStr(ResultType type) const {
-        static const wxChar* ResultTypeNames[] = {
-            wxT("OK"),
-            wxT(" F"),
-            wxT("ER")
+    wxString GetResultStr(ResultType type) const
+    {
+        static const char *resultTypeNames[] =
+        {
+            "  OK",
+            "FAIL",
+            " ERR"
         };
-        wxCHECK_MSG(static_cast<size_t>(type) < WXSIZEOF(ResultTypeNames),
-            ResultTypeNames[RESULT_ERROR], "invalid entry type");
-        return ResultTypeNames[type];
+
+        wxCOMPILE_TIME_ASSERT( WXSIZEOF(resultTypeNames) == RESULT_MAX,
+                               ResultTypeNamesMismatch );
+
+        return resultTypeNames[type];
     }
 
     bool m_timing;
@@ -376,24 +383,34 @@ extern void SetProcessEventFunc(ProcessEventFunc func)
 //
 int TestApp::OnRun()
 {
+#if wxUSE_LOG
+    // Switch off logging unless --verbose
+    bool verbose = wxLog::GetVerbose();
+    wxLog::EnableLogging(verbose);
+#else
+    bool verbose = false;
+#endif
+
     CppUnit::TextTestRunner runner;
 
     for (size_t i = 0; i < m_registries.size(); i++)
     {
         wxString reg = m_registries[i];
-        if (!reg.empty() && !reg.EndsWith("TestCase"))
-            reg += "TestCase";
         // allow the user to specify the name of the testcase "in short form"
         // (all wx test cases end with TestCase postfix)
+        if (!reg.empty() && !reg.EndsWith("TestCase"))
+            reg += "TestCase";
+
+        string stdreg(reg.mb_str());
 
         auto_ptr<Test> test(reg.empty() ?
             TestFactoryRegistry::getRegistry().makeTest() :
-            TestFactoryRegistry::getRegistry(string(reg.mb_str())).makeTest());
+            TestFactoryRegistry::getRegistry(stdreg).makeTest());
 
         TestSuite *suite = dynamic_cast<TestSuite*>(test.get());
 
         if (suite && suite->countTestCases() == 0)
-            wxLogError(_T("No such test suite: %s"), reg);
+            cerr << "No such test suite: " << stdreg << endl;
         else if (m_list)
             List(test.get());
         else
@@ -405,14 +422,6 @@ int TestApp::OnRun()
 
     runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), cout));
 
-#if wxUSE_LOG
-    // Switch off logging unless --verbose
-    bool verbose = wxLog::GetVerbose();
-    wxLog::EnableLogging(verbose);
-#else
-    bool verbose = false;
-#endif
-
     // there is a bug
     // (http://sf.net/tracker/index.php?func=detail&aid=1649369&group_id=11795&atid=111795)
     // in some versions of cppunit: they write progress dots to cout (and not