Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / API_CppTest / INC / cpptest-assert.h
diff --git a/WCudaMSE/API_CppTest/INC/cpptest-assert.h b/WCudaMSE/API_CppTest/INC/cpptest-assert.h
new file mode 100755 (executable)
index 0000000..8168aad
--- /dev/null
@@ -0,0 +1,331 @@
+// ---\r
+//\r
+// $Id: cpptest-assert.h,v 1.3 2005/06/08 08:08:06 nilu Exp $\r
+//\r
+// CppTest - A C++ Unit Testing Framework\r
+// Copyright (c) 2003 Niklas Lundell\r
+//\r
+// ---\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2 of the License, or (at your option) any later version.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the\r
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
+// Boston, MA 02111-1307, USA.\r
+//\r
+// ---\r
+\r
+/** \file */\r
+\r
+#ifndef CPPTEST_ASSERT_H\r
+#define CPPTEST_ASSERT_H\r
+\r
+/// Unconditional failure.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param msg Provided message.\r
+///\r
+/// \par Example:\r
+/// \code\r
+/// void MySuite::test()\r
+/// {\r
+///    // ...\r
+///\r
+///    switch (flag)\r
+///    {\r
+///            // handling valid cases ...\r
+///\r
+///            default:\r
+///                    TEST_FAIL("This should not happen")\r
+///    }\r
+/// }\r
+/// \endcode\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_FAIL(msg) \\r
+       {                                                                                                                               \\r
+               assertment(::Test::Source(__FILE__, __LINE__, (msg) != 0 ? #msg : "")); \\r
+               if (!continue_after_failure()) return;                                          \\r
+       }\r
+\r
+/// Verify an expression and issues an assertment if it fails.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+///\r
+/// \see TEST_ASSERT_MSG(expr, msg)\r
+///\r
+/// \par Example:\r
+/// \code\r
+/// void MySuite::test()\r
+/// {\r
+///    int i;\r
+///\r
+///    // ...\r
+///\r
+///    TEST_ASSERT(i == 13)\r
+/// }\r
+/// \endcode\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_ASSERT(expr)                                                                                      \\r
+       {                                                                                                                               \\r
+               if (!(expr))                                                                                            \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, #expr));  \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify an expression and issues an assertment if it fails.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+/// \param msg  User message.\r
+///\r
+/// \see TEST_ASSERT(expr)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_ASSERT_MSG(expr, msg)                                                                     \\r
+       {                                                                                                                               \\r
+               if (!(expr))                                                                                            \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, msg));    \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify that two expressions are equal up to a constant, issues an\r
+/// assertment if it fails.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param a     First expression to test.\r
+/// \param b     Second expression to test.\r
+/// \param delta Constant.\r
+///\r
+/// \see TEST_ASSERT_DELTA_MSG(a, b, delta, msg)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_ASSERT_DELTA(a, b, delta)                                                         \\r
+       {                                                                                                                               \\r
+               if (((b) < (a) - (delta)) || ((b) > (a) + (delta)))                     \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__,                   \\r
+                                          "delta(" #a ", " #b ", " #delta ")" ));              \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify that two expressions are equal up to a constant, issues an\r
+/// assertment if it fails.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param a     First expression to test.\r
+/// \param b     Second expression to test.\r
+/// \param delta Constant.\r
+/// \param msg   User message. \r
+///\r
+/// \see TEST_ASSERT_DELTA(a, b, delta)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_ASSERT_DELTA_MSG(a, b, delta, msg)                                                \\r
+       {                                                                                                                               \\r
+               if (((b) < (a) - (delta)) || ((b) > (a) + (delta)))                     \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, msg));    \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+       \r
+/// Verify an expression and expects an exception in return.\r
+/// An assertment is issued if the exception is not thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+/// \param x    Expected exception.\r
+///\r
+/// \see TEST_THROWS_MSG(expr, x, msg)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS(expr, x)                                                                           \\r
+       {                                                                                                                               \\r
+               bool __expected = false;                                                                        \\r
+               try { expr; }                                                                                           \\r
+               catch (x)                       { __expected = true; }                                  \\r
+               catch (...)                     {}                                                                              \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, #expr));  \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify an expression and expects an exception in return.\r
+/// An assertment is issued if the exception is not thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+/// \param x    Expected exception.\r
+/// \param msg  User message.\r
+///\r
+/// \see TEST_THROWS(expr, x)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS_MSG(expr, x, msg)                                                          \\r
+       {                                                                                                                               \\r
+               bool __expected = false;                                                                        \\r
+               try { expr; }                                                                                           \\r
+               catch (x)                       { __expected = true; }                                  \\r
+               catch (...)                     {}                                                                              \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, msg));    \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify an expression and expects any exception in return.\r
+/// An assertment is issued if no exception is thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+///\r
+/// \see TEST_THROWS_ANYTHING_MSG(expr, msg)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS_ANYTHING(expr)                                                                     \\r
+       {                                                                                                                               \\r
+               bool __expected = false;                                                                        \\r
+               try { expr; }                                                                                           \\r
+               catch (...) { __expected = true; }                                                      \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, #expr));  \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify an expression and expects any exception in return.\r
+/// An assertment is issued if no exception is thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+/// \param msg  User message.\r
+///\r
+/// \see TEST_THROWS_ANYTHING(expr)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS_ANYTHING_MSG(expr, msg)                                                    \\r
+       {                                                                                                                               \\r
+               bool __expected = false;                                                                        \\r
+               try { expr; }                                                                                           \\r
+               catch (...) { __expected = true; }                                                      \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, msg));    \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+       \r
+/// Verify an expression and expects no exception in return.\r
+/// An assertment is issued if any exception is thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+///\r
+/// \see TEST_THROWS_NOTHING_MSG(expr, msg)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS_NOTHING(expr)                                                                      \\r
+       {                                                                                                                               \\r
+               bool __expected = true;                                                                         \\r
+               try { expr; }                                                                                           \\r
+               catch (...) { __expected = false; }                                                     \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, #expr));  \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// Verify an expression and expects no exception in return.\r
+/// An assertment is issued if any exception is thrown.\r
+///\r
+/// Used in conjunction with Test::Suite.\r
+///\r
+/// \param expr Expression to test.\r
+/// \param msg  User message.\r
+///\r
+/// \see TEST_THROWS_NOTHING(expr)\r
+///\r
+/// For a description of all asserts, see \ref asserts.\r
+///\r
+#define TEST_THROWS_NOTHING_MSG(expr, msg)                                                     \\r
+       {                                                                                                                               \\r
+               bool __expected = true;                                                                         \\r
+               try { expr; }                                                                                           \\r
+               catch (...) { __expected = false; }                                                     \\r
+               if (!__expected)                                                                                        \\r
+               {                                                                                                                       \\r
+                       assertment(::Test::Source(__FILE__, __LINE__, msg));    \\r
+                       if (!continue_after_failure()) return;                                  \\r
+               }                                                                                                                       \\r
+       }\r
+\r
+/// \page asserts Available asserts\r
+///\r
+/// Normally, assert macros issues an assert if the given expression, if any,\r
+/// fails (as defined by the macro). Assertments include information about the\r
+/// current test suite, test function, source file, source file line, and a\r
+/// message. The message is normally the offending expression, however, for\r
+/// macros ending in _MSG it is possibly to supply a user defined message.\r
+///\r
+/// <b>General asserts</b>\r
+/// - TEST_FAIL(msg)\r
+///\r
+/// <b>Comparision asserts</b>\r
+/// - TEST_ASSERT(expr)\r
+/// - TEST_ASSERT_MSG(expr, msg)\r
+/// - TEST_ASSERT_DELTA(a, b, delta)\r
+/// - TEST_ASSERT_DELTA_MSG(a, b, delta, msg)\r
+///\r
+/// <b>Exception asserts</b>\r
+/// - TEST_THROWS(expr, x)\r
+/// - TEST_THROWS_MSG(expr, x, msg)\r
+/// - TEST_THROWS_ANYTHING(expr)\r
+/// - TEST_THROWS_ANYTHING_MSG(expr, msg)\r
+/// - TEST_THROWS_NOTHING(expr)\r
+/// - TEST_THROWS_NOTHING_MSG(expr, msg)\r
+///\r
+\r
+#endif // #ifndef CPPTEST_ASSERT_H\r
+\r