diff options
author | Alex Vakulenko <avakulenko@chromium.org> | 2014-08-28 16:48:57 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-01 11:05:16 +0000 |
commit | 88b591f24cb3f94f982d7024c2e8ed25c2cc26a2 (patch) | |
tree | d49741d0b0926c4c387e9d618b990ae89e6d2f8e /update_manager/umtest_utils.h | |
parent | f3e2801f18bae14e41099e007de7c9a019735556 (diff) |
update_engine: Replace NULL with nullptr
Replaced the usage of NULL with nullptr. This also makes it possible to
use standard gtest macros to compare pointers in Update Manager's unit tests.
So, there is no need in custom UMTEST_... macros which are replaced with the
gtest macros (see change in update_engine/update_manager/umtest_utils.h):
UMTEST_ASSERT_NULL(p) => ASSERT_EQ(nullptr, p)
UMTEST_ASSERT_NOT_NULL(p) => ASSERT_NE(nullptr, p)
UMTEST_EXPECT_NULL(p) => EXPECT_EQ(nullptr, p)
UMTEST_EXPECT_NOT_NULL(p) => EXPECT_NE(nullptr, p)
BUG=None
TEST=FEATURES=test emerge-link update_engine
USE="clang asan" FEATURES=test emerge-link update_engine
Change-Id: I77a42a1e9ce992bb2f9f263db5cf75fe6110a4ec
Reviewed-on: https://chromium-review.googlesource.com/215136
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Diffstat (limited to 'update_manager/umtest_utils.h')
-rw-r--r-- | update_manager/umtest_utils.h | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/update_manager/umtest_utils.h b/update_manager/umtest_utils.h index 3c9036e2..4e2de8e8 100644 --- a/update_manager/umtest_utils.h +++ b/update_manager/umtest_utils.h @@ -14,22 +14,6 @@ #include "update_engine/update_manager/policy.h" #include "update_engine/update_manager/variable.h" -// Convenience macros for checking null-ness of pointers. -// -// Purportedly, gtest should support pointer comparison when the first argument -// is a pointer (e.g. NULL). It is therefore appropriate to use -// {ASSERT,EXPECT}_{EQ,NE} for our purposes. However, gtest fails to realize -// that NULL is a pointer when used with the _NE variants, unless we explicitly -// cast it to a pointer type, and so we inject this casting. -// -// Note that checking nullness of the content of a scoped_ptr requires getting -// the inner pointer value via get(). -#define UMTEST_ASSERT_NULL(p) ASSERT_EQ(NULL, p) -#define UMTEST_ASSERT_NOT_NULL(p) ASSERT_NE(reinterpret_cast<void*>(NULL), p) -#define UMTEST_EXPECT_NULL(p) EXPECT_EQ(NULL, p) -#define UMTEST_EXPECT_NOT_NULL(p) EXPECT_NE(reinterpret_cast<void*>(NULL), p) - - namespace chromeos_update_manager { // A help class with common functionality for use in Update Manager testing. @@ -43,18 +27,18 @@ class UmTestUtils { // Calls GetValue on |variable| and expects its result to be |expected|. template<typename T> static void ExpectVariableHasValue(const T& expected, Variable<T>* variable) { - UMTEST_ASSERT_NOT_NULL(variable); + ASSERT_NE(nullptr, variable); scoped_ptr<const T> value(variable->GetValue(DefaultTimeout(), nullptr)); - UMTEST_ASSERT_NOT_NULL(value.get()) << "Variable: " << variable->GetName(); + ASSERT_NE(nullptr, value.get()) << "Variable: " << variable->GetName(); EXPECT_EQ(expected, *value) << "Variable: " << variable->GetName(); } // Calls GetValue on |variable| and expects its result to be null. template<typename T> static void ExpectVariableNotSet(Variable<T>* variable) { - UMTEST_ASSERT_NOT_NULL(variable); + ASSERT_NE(nullptr, variable); scoped_ptr<const T> value(variable->GetValue(DefaultTimeout(), nullptr)); - UMTEST_EXPECT_NULL(value.get()) << "Variable: " << variable->GetName(); + EXPECT_EQ(nullptr, value.get()) << "Variable: " << variable->GetName(); } private: |