michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * This attempts to test all the possible variations of |operator==| michael@0: * used with |nsCOMPtr|s. Currently only the tests where pointers michael@0: * are to the same class are enabled. It's not clear whether we michael@0: * should be supporting other tests, and some of them won't work michael@0: * on at least some platforms. If we add separate comparisons michael@0: * for nsCOMPtr we'll need to add more tests for michael@0: * those cases. michael@0: */ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: michael@0: // Don't test these now, since some of them won't work and it's michael@0: // not clear whether they should (see above). michael@0: #undef NSCAP_EQTEST_TEST_ACROSS_TYPES michael@0: michael@0: #define NS_ICOMPTREQTESTFOO_IID \ michael@0: {0x8eb5bbef, 0xd1a3, 0x4659, \ michael@0: {0x9c, 0xf6, 0xfd, 0xf3, 0xe4, 0xd2, 0x00, 0x0e}} michael@0: michael@0: class nsICOMPtrEqTestFoo : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO_IID) michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo, NS_ICOMPTREQTESTFOO_IID) michael@0: michael@0: #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES michael@0: michael@0: #define NS_ICOMPTREQTESTFOO2_IID \ michael@0: {0x6516387b, 0x36c5, 0x4036, \ michael@0: {0x82, 0xc9, 0xa7, 0x4d, 0xd9, 0xe5, 0x92, 0x2f}} michael@0: michael@0: class nsICOMPtrEqTestFoo2 : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO2_IID) michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo2, NS_ICOMPTREQTESTFOO2_IID) michael@0: michael@0: #endif michael@0: michael@0: int michael@0: main() michael@0: { michael@0: nsCOMPtr s; michael@0: nsICOMPtrEqTestFoo* r = 0; michael@0: const nsCOMPtr sc; michael@0: const nsICOMPtrEqTestFoo* rc = 0; michael@0: nsICOMPtrEqTestFoo* const rk = 0; michael@0: const nsICOMPtrEqTestFoo* const rkc = 0; michael@0: nsICOMPtrEqTestFoo* d = s; michael@0: michael@0: #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES michael@0: nsCOMPtr s2; michael@0: nsICOMPtrEqTestFoo2* r2 = 0; michael@0: const nsCOMPtr sc2; michael@0: const nsICOMPtrEqTestFoo2* rc2 = 0; michael@0: nsICOMPtrEqTestFoo2* const rk2 = 0; michael@0: const nsICOMPtrEqTestFoo2* const rkc2 = 0; michael@0: nsICOMPtrEqTestFoo2* d2 = s2; michael@0: #endif michael@0: michael@0: return (!(true && michael@0: (s == s) && michael@0: (s == r) && michael@0: (s == sc) && michael@0: (s == rc) && michael@0: (s == rk) && michael@0: (s == rkc) && michael@0: (s == d) && michael@0: (r == s) && michael@0: (r == sc) && michael@0: (r == rc) && michael@0: (r == rk) && michael@0: (r == rkc) && michael@0: (r == d) && michael@0: (sc == s) && michael@0: (sc == r) && michael@0: (sc == sc) && michael@0: (sc == rc) && michael@0: (sc == rk) && michael@0: (sc == rkc) && michael@0: (sc == d) && michael@0: (rc == s) && michael@0: (rc == r) && michael@0: (rc == sc) && michael@0: (rc == rk) && michael@0: (rc == rkc) && michael@0: (rc == d) && michael@0: (rk == s) && michael@0: (rk == r) && michael@0: (rk == sc) && michael@0: (rk == rc) && michael@0: (rk == rkc) && michael@0: (rk == d) && michael@0: (rkc == s) && michael@0: (rkc == r) && michael@0: (rkc == sc) && michael@0: (rkc == rc) && michael@0: (rkc == rk) && michael@0: (rkc == d) && michael@0: (d == s) && michael@0: (d == r) && michael@0: (d == sc) && michael@0: (d == rc) && michael@0: (d == rk) && michael@0: (d == rkc) && michael@0: #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES michael@0: (s == s2) && michael@0: (s == r2) && michael@0: (s == sc2) && michael@0: (s == rc2) && michael@0: (s == rk2) && michael@0: (s == rkc2) && michael@0: (s == d2) && michael@0: (r == s2) && michael@0: (r == r2) && michael@0: (r == sc2) && michael@0: (r == rc2) && michael@0: (r == rk2) && michael@0: (r == rkc2) && michael@0: (r == d2) && michael@0: (sc == s2) && michael@0: (sc == r2) && michael@0: (sc == sc2) && michael@0: (sc == rc2) && michael@0: (sc == rk2) && michael@0: (sc == rkc2) && michael@0: (sc == d2) && michael@0: (rc == s2) && michael@0: (rc == r2) && michael@0: (rc == sc2) && michael@0: (rc == rc2) && michael@0: (rc == rk2) && michael@0: (rc == rkc2) && michael@0: (rc == d2) && michael@0: (rk == s2) && michael@0: (rk == r2) && michael@0: (rk == sc2) && michael@0: (rk == rc2) && michael@0: (rk == rk2) && michael@0: (rk == rkc2) && michael@0: (rk == d2) && michael@0: (rkc == s2) && michael@0: (rkc == r2) && michael@0: (rkc == sc2) && michael@0: (rkc == rc2) && michael@0: (rkc == rk2) && michael@0: (rkc == rkc2) && michael@0: (rkc == d2) && michael@0: (d == s2) && michael@0: (d == r2) && michael@0: (d == sc2) && michael@0: (d == rc2) && michael@0: (d == rk2) && michael@0: (d == rkc2) && michael@0: (d == d2) && michael@0: #endif michael@0: true)); michael@0: }