From 9251373a4ca35e35c6d1d2740e6c958a85f0a329 Mon Sep 17 00:00:00 2001 From: Tim King Date: Mon, 31 Oct 2011 21:43:11 +0000 Subject: [PATCH] Added assertions to the CLN implementation of Integer for getLong() and getUnsignedLong(). --- src/util/integer_cln_imp.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h index 6e2ca3500..b7a35fee8 100644 --- a/src/util/integer_cln_imp.h +++ b/src/util/integer_cln_imp.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "util/Assert.h" @@ -245,12 +246,14 @@ public: //friend std::ostream& operator<<(std::ostream& os, const Integer& n); long getLong() const { - // supposed to throw if not representable in type "long" + Assert(d_value <= std::numeric_limits::max()); + Assert(d_value >= std::numeric_limits::min()); return cln::cl_I_to_long(d_value); } unsigned long getUnsignedLong() const { - // supposed to throw if not representable in type "unsigned long" + Assert(d_value <= std::numeric_limits::max()); + Assert(d_value >= std::numeric_limits::min()); return cln::cl_I_to_ulong(d_value); } -- 2.30.2