From 043523a79489307810b284c638a953fb4f600aa3 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 29 May 2015 15:51:25 +1000 Subject: [PATCH] debug: add CHECK_LIMIT --- debug.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/debug.hpp b/debug.hpp index 325345d3..cf17f60c 100644 --- a/debug.hpp +++ b/debug.hpp @@ -177,6 +177,26 @@ } while (0) +/////////////////////////////////////////////////////////////////////////////// +#define CHECK_LIMIT(VAL,LO,HI) do { \ + DEBUG_ONLY( \ + const auto __val = (VAL); \ + const auto __hi = (HI); \ + const auto __lo = (LO); \ + \ + _CHECK_META (__val >= __lo && __val <= __hi, \ + { ; }, \ + { \ + std::ostringstream __os; \ + __os << "expected satisifies limit\n" \ + << "__val: " << #VAL << " = " << __val << '\n' \ + << "__lo: " << #LO << " = " << __lo << '\n' \ + << "__hi: " << #HI << " = " << __hi << '\n'; \ + panic (__os.str ()); \ + }); \ + ); \ +} while (0) + /////////////////////////////////////////////////////////////////////////////// #define CHECK_NEQ(A,B) do { \ DEBUG_ONLY( \