blob: 6adfec4b026e51ed0fb17c0877a837c87bd0957b [file] [log] [blame]
Gilad Arnolda87340b2014-01-30 11:10:18 -08001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PMTEST_UTILS_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PMTEST_UTILS_H
7
8// Convenience macros for checking null-ness of pointers.
9//
10// Purportedly, gtest should support pointer comparison when the first argument
11// is a pointer (e.g. NULL). It is therefore appropriate to use
12// {ASSERT,EXPECT}_{EQ,NE} for our purposes. However, gtest fails to realize
13// that NULL is a pointer when used with the _NE variants, unless we explicitly
14// cast it to a pointer type, and so we inject this casting.
15//
16// Note that checking nullness of the content of a scoped_ptr requires getting
17// the inner pointer value via get().
18#define PMTEST_ASSERT_NULL(p) ASSERT_EQ(NULL, p)
19#define PMTEST_ASSERT_NOT_NULL(p) ASSERT_NE(reinterpret_cast<void*>(NULL), p)
20#define PMTEST_EXPECT_NULL(p) EXPECT_EQ(NULL, p)
21#define PMTEST_EXPECT_NOT_NULL(p) EXPECT_NE(reinterpret_cast<void*>(NULL), p)
22
23#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PMTEST_UTILS_H