1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is TestCOMPtrEq.cpp.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
23 * L. David Baron <dbaron@dbaron.org> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * This attempts to test all the possible variations of |operator==|
41 * used with |nsCOMPtr|s. Currently only the tests where pointers
42 * are to the same class are enabled. It's not clear whether we
43 * should be supporting other tests, and some of them won't work
44 * on at least some platforms. If we add separate comparisons
45 * for nsCOMPtr<nsISupports> we'll need to add more tests for
51 // Don't test these now, since some of them won't work and it's
52 // not clear whether they should (see above).
53 #undef NSCAP_EQTEST_TEST_ACROSS_TYPES
55 #define NS_ICOMPTREQTESTFOO_IID \
56 {0x8eb5bbef, 0xd1a3, 0x4659, \
57 {0x9c, 0xf6, 0xfd, 0xf3, 0xe4, 0xd2, 0x00, 0x0e}}
59 class nsICOMPtrEqTestFoo
: public nsISupports
{
61 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO_IID
)
64 NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo
, NS_ICOMPTREQTESTFOO_IID
)
66 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
68 #define NS_ICOMPTREQTESTFOO2_IID \
69 {0x6516387b, 0x36c5, 0x4036, \
70 {0x82, 0xc9, 0xa7, 0x4d, 0xd9, 0xe5, 0x92, 0x2f}}
72 class nsICOMPtrEqTestFoo2
: public nsISupports
{
74 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO2_IID
)
77 NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo2
, NS_ICOMPTREQTESTFOO2_IID
)
84 nsCOMPtr
<nsICOMPtrEqTestFoo
> s
;
85 nsICOMPtrEqTestFoo
* r
= 0;
86 const nsCOMPtr
<nsICOMPtrEqTestFoo
> sc
;
87 const nsICOMPtrEqTestFoo
* rc
= 0;
88 nsICOMPtrEqTestFoo
* const rk
= 0;
89 const nsICOMPtrEqTestFoo
* const rkc
= 0;
90 nsICOMPtrEqTestFoo
* d
= s
;
92 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
93 nsCOMPtr
<nsICOMPtrEqTestFoo2
> s2
;
94 nsICOMPtrEqTestFoo2
* r2
= 0;
95 const nsCOMPtr
<nsICOMPtrEqTestFoo2
> sc2
;
96 const nsICOMPtrEqTestFoo2
* rc2
= 0;
97 nsICOMPtrEqTestFoo2
* const rk2
= 0;
98 const nsICOMPtrEqTestFoo2
* const rkc2
= 0;
99 nsICOMPtrEqTestFoo2
* d2
= s2
;
152 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES