From db62693535471faef1cdd99a838b054ea905a1da Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 12 Feb 2014 17:05:37 +1100 Subject: [PATCH] Add CHECK_GE and CHECK_LE --- debug.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/debug.hpp b/debug.hpp index 581cd07a..9eb43512 100644 --- a/debug.hpp +++ b/debug.hpp @@ -128,6 +128,23 @@ } while (0) +#define CHECK_LE(A,B) do { \ + const auto __a = (A); \ + const auto __b = (B); \ + _CHECK_META (__a <= __b, \ + { ; }, \ + { \ + std::ostringstream __debug_check_lt_os; \ + __debug_check_lt_os \ + << "expected less or equal to\n" \ + << "__a: " << #A << " is " << __a << ")" \ + << "\n > \n" \ + << "__b: " << #B << " is " << __b << ")"; \ + panic (__debug_check_lt_os.str ()); \ + }); \ +} while (0) + + #define CHECK_GT(A,B) do { \ const auto __a = (A); \ const auto __b = (B); \ @@ -145,6 +162,23 @@ } while (0) +#define CHECK_GE(A,B) do { \ + const auto __a = (A); \ + const auto __b = (B); \ + _CHECK_META (__a >= __b, \ + { ; }, \ + { \ + std::ostringstream __debug_check_gt_os; \ + __debug_check_gt_os \ + << "expected greater or equal to.\n" \ + << "__a: " << #A << " is " << __a << ")" \ + << "\n < \n" \ + << "__b: " << #B << " is " << __b << ")"; \ + panic (__debug_check_gt_os.str ()); \ + }); \ +} while (0) + + #define CHECK_NEQ(A,B) do { \ const auto __a = (A); \ const auto __b = (B); \