summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author <shinichiro.hamaji@gmail.com>2010-05-28 03:43:29 +0000
committer <shinichiro.hamaji@gmail.com>2010-05-28 03:43:29 +0000
commit9e15c473b79c1e70f2be1f4e701b9c345da4217c (patch)
treeb5ab9b05aa23d108de2615ca9030e5396ef373f4
parentb2704e9f078b79c1c3b285710ec1739fd280443c (diff)
downloadglog-9e15c473b79c1e70f2be1f4e701b9c345da4217c.tar.gz
glog-9e15c473b79c1e70f2be1f4e701b9c345da4217c.tar.bz2
glog-9e15c473b79c1e70f2be1f4e701b9c345da4217c.zip
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
-rw-r--r--src/glog/logging.h.in3
-rw-r--r--src/logging_unittest.cc5
-rwxr-xr-xsrc/windows/glog/logging.h3
3 files changed, 11 insertions, 0 deletions
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 <iomanip>
#include <iostream>
+#include <memory>
#include <queue>
#include <sstream>
#include <string>
@@ -555,6 +556,10 @@ void TestDCHECK() {
DCHECK_LE(1, 2);
DCHECK_GT(2, 1);
DCHECK_LT(1, 2);
+
+ auto_ptr<int64> 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)