summaryrefslogtreecommitdiff
path: root/update_manager/umtest_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'update_manager/umtest_utils.h')
-rw-r--r--update_manager/umtest_utils.h24
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: