Bug 1883861 - Part 1: Move visitMemoryBarrier into the common CodeGenerator file...
[gecko.git] / xpcom / tests / gtest / TestCOMPtrEq.cpp
blob2056ce136805c181164607463875852382f6faf5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /**
7 * This attempts to test all the possible variations of |operator==|
8 * used with |nsCOMPtr|s.
9 */
11 #include "nsCOMPtr.h"
12 #include "gtest/gtest.h"
14 #define NS_ICOMPTREQTESTFOO_IID \
15 { \
16 0x8eb5bbef, 0xd1a3, 0x4659, { \
17 0x9c, 0xf6, 0xfd, 0xf3, 0xe4, 0xd2, 0x00, 0x0e \
18 } \
21 class nsICOMPtrEqTestFoo : public nsISupports {
22 public:
23 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO_IID)
26 NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo, NS_ICOMPTREQTESTFOO_IID)
28 TEST(COMPtrEq, NullEquality)
30 nsCOMPtr<nsICOMPtrEqTestFoo> s;
31 nsICOMPtrEqTestFoo* r = nullptr;
32 const nsCOMPtr<nsICOMPtrEqTestFoo> sc;
33 const nsICOMPtrEqTestFoo* rc = nullptr;
34 nsICOMPtrEqTestFoo* const rk = nullptr;
35 const nsICOMPtrEqTestFoo* const rkc = nullptr;
36 nsICOMPtrEqTestFoo* d = s;
38 ASSERT_EQ(s, s);
39 ASSERT_EQ(s, r);
40 ASSERT_EQ(s, sc);
41 ASSERT_EQ(s, rc);
42 ASSERT_EQ(s, rk);
43 ASSERT_EQ(s, rkc);
44 ASSERT_EQ(s, d);
45 ASSERT_EQ(r, s);
46 ASSERT_EQ(r, sc);
47 ASSERT_EQ(r, rc);
48 ASSERT_EQ(r, rk);
49 ASSERT_EQ(r, rkc);
50 ASSERT_EQ(r, d);
51 ASSERT_EQ(sc, s);
52 ASSERT_EQ(sc, r);
53 ASSERT_EQ(sc, sc);
54 ASSERT_EQ(sc, rc);
55 ASSERT_EQ(sc, rk);
56 ASSERT_EQ(sc, rkc);
57 ASSERT_EQ(sc, d);
58 ASSERT_EQ(rc, s);
59 ASSERT_EQ(rc, r);
60 ASSERT_EQ(rc, sc);
61 ASSERT_EQ(rc, rk);
62 ASSERT_EQ(rc, rkc);
63 ASSERT_EQ(rc, d);
64 ASSERT_EQ(rk, s);
65 ASSERT_EQ(rk, r);
66 ASSERT_EQ(rk, sc);
67 ASSERT_EQ(rk, rc);
68 ASSERT_EQ(rk, rkc);
69 ASSERT_EQ(rk, d);
70 ASSERT_EQ(rkc, s);
71 ASSERT_EQ(rkc, r);
72 ASSERT_EQ(rkc, sc);
73 ASSERT_EQ(rkc, rc);
74 ASSERT_EQ(rkc, rk);
75 ASSERT_EQ(rkc, d);
76 ASSERT_EQ(d, s);
77 ASSERT_EQ(d, r);
78 ASSERT_EQ(d, sc);
79 ASSERT_EQ(d, rc);
80 ASSERT_EQ(d, rk);
81 ASSERT_EQ(d, rkc);