From 9e15c473b79c1e70f2be1f4e701b9c345da4217c Mon Sep 17 00:00:00 2001 From: Date: Fri, 28 May 2010 03:43:29 +0000 Subject: [PATCH] Add DCHECK_NOTNULL macro to logging.h (points to CHECK_NOTNULL in debug mode) http://code.google.com/p/google-glog/issues/detail?id=25 git-svn-id: https://google-glog.googlecode.com/svn/trunk@83 eb4d4688-79bd-11dd-afb4-1d65580434c0 --- src/glog/logging.h.in | 3 +++ src/logging_unittest.cc | 5 +++++ src/windows/glog/logging.h | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in index 30b7e5c..16ba694 100644 --- a/src/glog/logging.h.in +++ b/src/glog/logging.h.in @@ -889,6 +889,7 @@ enum PRIVATE_Counter {COUNTER}; #define DCHECK_LT(val1, val2) CHECK_LT(val1, val2) #define DCHECK_GE(val1, val2) CHECK_GE(val1, val2) #define DCHECK_GT(val1, val2) CHECK_GT(val1, val2) +#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val) #define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2) #define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2) #define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2) @@ -943,6 +944,8 @@ enum PRIVATE_Counter {COUNTER}; while (false) \ CHECK_GT(val1, val2) +#define DCHECK_NOTNULL(val) (val) + #define DCHECK_STREQ(str1, str2) \ while (false) \ CHECK_STREQ(str1, str2) diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index 76bf31b..427afe5 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -555,6 +556,10 @@ void TestDCHECK() { DCHECK_LE(1, 2); DCHECK_GT(2, 1); DCHECK_LT(1, 2); + + auto_ptr sptr(new int64); + int64* ptr = DCHECK_NOTNULL(sptr.get()); + ASSERT_EQ(ptr, sptr.get()); } void TestSTREQ() { diff --git a/src/windows/glog/logging.h b/src/windows/glog/logging.h index 2e8f2da..a63246d 100755 --- a/src/windows/glog/logging.h +++ b/src/windows/glog/logging.h @@ -893,6 +893,7 @@ enum PRIVATE_Counter {COUNTER}; #define DCHECK_LT(val1, val2) CHECK_LT(val1, val2) #define DCHECK_GE(val1, val2) CHECK_GE(val1, val2) #define DCHECK_GT(val1, val2) CHECK_GT(val1, val2) +#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val) #define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2) #define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2) #define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2) @@ -947,6 +948,8 @@ enum PRIVATE_Counter {COUNTER}; while (false) \ CHECK_GT(val1, val2) +#define DCHECK_NOTNULL(val) (val) + #define DCHECK_STREQ(str1, str2) \ while (false) \ CHECK_STREQ(str1, str2) -- 2.7.4