[opengtl-commits] [557] add macro that exist a test if test fails

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 557
Author:   cyrille
Date:     2009-02-22 21:00:19 +0100 (Sun, 22 Feb 2009)

Log Message:
-----------
add macro that exist a test if test fails

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLTest/Case.h


Modified: trunk/OpenGTL/OpenGTL/GTLTest/Case.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLTest/Case.h	2008-12-28 19:37:19 UTC (rev 556)
+++ trunk/OpenGTL/OpenGTL/GTLTest/Case.h	2009-02-22 20:00:19 UTC (rev 557)
@@ -32,6 +32,14 @@
   GTLTEST_CHECK_MESSAGE( (a), #a);
 
 /**
+ * Check that a is true and display a message containing the value.
+ * Stop the test if failed;
+ * @ingroup GTLTest
+ */
+#define GTLTEST_CHECK_REQUIRED(a) \
+  GTLTEST_CHECK_MESSAGE_REQUIRED( (a), #a);
+
+/**
  * This macro will test that a and b are strictly equal, and display a message containing the values
  * in case of failure.
  * @ingroup GTLTest
@@ -66,6 +74,22 @@
     ss << __FILE__ << " at " << __LINE__ << ": " << msg; \
     check( (a), ss.str()); \
   }
+
+/**
+ * This macro will display the message including the file and line number, in case of failure.
+ * @ingroup GTLTest
+ */
+#define GTLTEST_CHECK_MESSAGE_REQUIRED(a, msg) \
+  { \
+    std::stringstream ss; \
+    std::string str; \
+    ss << __FILE__ << " at " << __LINE__ << ": " << msg; \
+    bool t = (a); \
+    check( t, ss.str()); \
+    if(not t) \
+      return; \
+  }
+
 namespace GTLTest {
   class Suite;
   class Result;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/