Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / auto_unit_test.hh
index f93ae3c..95980e3 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
-// Copyright (C) 2007 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer NETwork research (NET)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
     unit tests. If the available Boost version is 1.34, this file will automatically take care of
     any necessary workarounds.
 
-    So, instead of <tt>#include <boost/test/auto_unit_test.hpp></tt>, you should always write
-    <tt>#include "../Utils/auto_unit_test.hh"<tt> (with possibliy adjusted path).
+    So, instead of <tt>\#include <boost/test/auto_unit_test.hpp></tt>, you should always write
+    <pre>
+    \#include "../Utils/auto_unit_test.hh"
+    </pre> (with possibliy adjusted path).
  */
 
-#ifndef HH_auto_unit_test_
-#define HH_auto_unit_test_ 1
+#ifndef HH_SENF_Utils_auto_unit_test_
+#define HH_SENF_Utils_auto_unit_test_ 1
 
 // Custom includes
 #include <boost/version.hpp>
 
 #include <boost/test/auto_unit_test.hpp>
 
+/** \defgroup unittest Boost.Test extensions
+
+    This module defines some additional extensions to Boost.Test
+ */
+
+/** \brief Check for compile failure
+
+    COMPILE_RAIL() is used to check, that a certain piece of code will produce a compile time
+    failure.
+
+    \code
+    #ifdef COMPILE_CHECK
+
+    COMPILE_FAIL(foo)
+    {
+        // fails to compile ....
+        int x = "foo";
+    }
+    
+    COMPILE_FAIL(bar)
+    { ... }
+
+    #endif
+    \endcode
+
+    This check is performed by the extended unit-test builder in \c senfscons.
+    
+    \ingroup unittest
+ */
+#define COMPILE_FAIL(n) void n()
+
+/** \brief Show exception information
+
+    \ref SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the
+    unabridged exception information when an exception is thrown in addition to signaling an error.
+
+    \ingroup unittest
+ */
+#define SENF_CHECK_NO_THROW(expr)                                                                 \
+    BOOST_CHECK_NO_THROW(                                                                         \
+        try { expr ; }                                                                            \
+        catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } )
+
 ///////////////////////////////hh.e////////////////////////////////////////
 //#include "auto_unit_test.cci"
 //#include "auto_unit_test.ct"