]> git.stg.codes - stg.git/blobdiff - tests/tut/tut_console_reporter.hpp
Check that IP is not in use before changing.
[stg.git] / tests / tut / tut_console_reporter.hpp
index 3c3739be49bdc48e15d62096a1a5007e4d4d08cb..33856db864bec88b3d1c5fdf4b9428d34c505f7d 100644 (file)
@@ -1,6 +1,5 @@
 #ifndef TUT_CONSOLE_REPORTER
 #define TUT_CONSOLE_REPORTER
 #ifndef TUT_CONSOLE_REPORTER
 #define TUT_CONSOLE_REPORTER
-
 #include <tut/tut.hpp>
 #include <cassert>
 
 #include <tut/tut.hpp>
 #include <cassert>
 
@@ -17,29 +16,32 @@ std::ostream& operator<<(std::ostream& os, const tut::test_result& tr)
 {
     switch(tr.result)
     {
 {
     switch(tr.result)
     {
-    case tut::test_result::ok:
-        os << '.';
-        break;
-    case tut::test_result::fail:
-        os << '[' << tr.test << "=F]";
-        break;
-    case tut::test_result::ex_ctor:
-        os << '[' << tr.test << "=C]";
-        break;
-    case tut::test_result::ex:
-        os << '[' << tr.test << "=X]";
-        break;
-    case tut::test_result::warn:
-        os << '[' << tr.test << "=W]";
-        break;
-    case tut::test_result::term:
-        os << '[' << tr.test << "=T]";
-        break;
-    case tut::test_result::rethrown:
-        os << '[' << tr.test << "=P]";
-        break;
-    case tut::test_result::dummy:
-        assert(!"Should never be called");
+        case tut::test_result::ok:
+            os << '.';
+            break;
+        case tut::test_result::fail:
+            os << '[' << tr.test << "=F]";
+            break;
+        case tut::test_result::ex_ctor:
+            os << '[' << tr.test << "=C]";
+            break;
+        case tut::test_result::ex:
+            os << '[' << tr.test << "=X]";
+            break;
+        case tut::test_result::warn:
+            os << '[' << tr.test << "=W]";
+            break;
+        case tut::test_result::term:
+            os << '[' << tr.test << "=T]";
+            break;
+        case tut::test_result::rethrown:
+            os << '[' << tr.test << "=P]";
+            break;
+        case tut::test_result::skipped:
+            os << '[' << tr.test << "=S]";
+            break;
+        case tut::test_result::dummy:
+            throw tut::tut_error("console reporter called for dummy test result");
     }
 
     return os;
     }
 
     return os;
@@ -60,6 +62,8 @@ class console_reporter : public tut::callback
     not_passed_list not_passed;
     std::ostream& os;
 
     not_passed_list not_passed;
     std::ostream& os;
 
+    console_reporter(const console_reporter &);
+    console_reporter &operator=(const console_reporter &);
 public:
 
     int ok_count;
 public:
 
     int ok_count;
@@ -67,15 +71,33 @@ public:
     int failures_count;
     int terminations_count;
     int warnings_count;
     int failures_count;
     int terminations_count;
     int warnings_count;
+    int skipped_count;
 
     console_reporter()
 
     console_reporter()
-        : os(std::cout)
+        : current_group(),
+          not_passed(),
+          os(std::cout),
+          ok_count(0),
+          exceptions_count(0),
+          failures_count(0),
+          terminations_count(0),
+          warnings_count(0),
+          skipped_count(0)
     {
         init();
     }
 
     console_reporter(std::ostream& out)
     {
         init();
     }
 
     console_reporter(std::ostream& out)
-        : os(out)
+        : current_group(),
+          not_passed(),
+          os(out),
+          ok_count(0),
+          exceptions_count(0),
+          failures_count(0),
+          terminations_count(0),
+          warnings_count(0),
+          skipped_count(0)
+
     {
         init();
     }
     {
         init();
     }
@@ -114,11 +136,15 @@ public:
             case test_result::term:
                 terminations_count++;
                 break;
             case test_result::term:
                 terminations_count++;
                 break;
+            case test_result::skipped:
+                skipped_count++;
+                break;
             case tut::test_result::dummy:
             case tut::test_result::dummy:
-                assert(!"Should never be called");
+                assert( (tr.result != tut::test_result::dummy) && "Should never be called");
         } // switch
 
         } // switch
 
-        if (tr.result != tut::test_result::ok)
+        if ( (tr.result != tut::test_result::ok) &&
+             (tr.result != tut::test_result::skipped) )
         {
             not_passed.push_back(tr);
         }
         {
             not_passed.push_back(tr);
         }
@@ -181,12 +207,12 @@ public:
                 {
                     if (tr.result == test_result::fail)
                     {
                 {
                     if (tr.result == test_result::fail)
                     {
-                        os << "     failed assertion: \"" << tr.message << "\""
+                        os << "     failed assertion: `" << tr.message << "`"
                             << std::endl;
                     }
                     else
                     {
                             << std::endl;
                     }
                     else
                     {
-                        os << "     message: \"" << tr.message << "\""
+                        os << "     message: `" << tr.message << "`"
                             << std::endl;
                     }
                 }
                             << std::endl;
                     }
                 }
@@ -214,11 +240,17 @@ public:
         {
             os << " warnings:" << warnings_count;
         }
         {
             os << " warnings:" << warnings_count;
         }
+
         os << " ok:" << ok_count;
         os << " ok:" << ok_count;
+
+        if(skipped_count > 0)
+        {
+            os << " skipped:" << skipped_count;
+        }
         os << std::endl;
     }
 
         os << std::endl;
     }
 
-    bool all_ok() const
+    virtual bool all_ok() const
     {
         return not_passed.empty();
     }
     {
         return not_passed.empty();
     }
@@ -232,6 +264,7 @@ private:
         failures_count = 0;
         terminations_count = 0;
         warnings_count = 0;
         failures_count = 0;
         terminations_count = 0;
         warnings_count = 0;
+        skipped_count = 0;
         not_passed.clear();
     }
 };
         not_passed.clear();
     }
 };