Bug 548621 - Create suite of tests for JS parsing speed. r=jorendorff.
[mozilla-central.git] / xpcom / tests / TestCOMPtrEq.cpp
blob97dc45f7bcf793129e0f583cca83b9bb25cef381
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
13 * License.
15 * The Original Code is TestCOMPtrEq.cpp.
17 * The Initial Developer of the Original Code is
18 * L. David Baron.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
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 ***** */
39 /**
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
46 * those cases.
49 #include "nsCOMPtr.h"
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 {
60 public:
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 {
73 public:
74 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO2_IID)
77 NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo2, NS_ICOMPTREQTESTFOO2_IID)
79 #endif
81 int
82 main()
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;
100 #endif
102 return (!(PR_TRUE &&
103 (s == s) &&
104 (s == r) &&
105 (s == sc) &&
106 (s == rc) &&
107 (s == rk) &&
108 (s == rkc) &&
109 (s == d) &&
110 (r == s) &&
111 (r == r) &&
112 (r == sc) &&
113 (r == rc) &&
114 (r == rk) &&
115 (r == rkc) &&
116 (r == d) &&
117 (sc == s) &&
118 (sc == r) &&
119 (sc == sc) &&
120 (sc == rc) &&
121 (sc == rk) &&
122 (sc == rkc) &&
123 (sc == d) &&
124 (rc == s) &&
125 (rc == r) &&
126 (rc == sc) &&
127 (rc == rc) &&
128 (rc == rk) &&
129 (rc == rkc) &&
130 (rc == d) &&
131 (rk == s) &&
132 (rk == r) &&
133 (rk == sc) &&
134 (rk == rc) &&
135 (rk == rk) &&
136 (rk == rkc) &&
137 (rk == d) &&
138 (rkc == s) &&
139 (rkc == r) &&
140 (rkc == sc) &&
141 (rkc == rc) &&
142 (rkc == rk) &&
143 (rkc == rkc) &&
144 (rkc == d) &&
145 (d == s) &&
146 (d == r) &&
147 (d == sc) &&
148 (d == rc) &&
149 (d == rk) &&
150 (d == rkc) &&
151 (d == d) &&
152 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
153 (s == s2) &&
154 (s == r2) &&
155 (s == sc2) &&
156 (s == rc2) &&
157 (s == rk2) &&
158 (s == rkc2) &&
159 (s == d2) &&
160 (r == s2) &&
161 (r == r2) &&
162 (r == sc2) &&
163 (r == rc2) &&
164 (r == rk2) &&
165 (r == rkc2) &&
166 (r == d2) &&
167 (sc == s2) &&
168 (sc == r2) &&
169 (sc == sc2) &&
170 (sc == rc2) &&
171 (sc == rk2) &&
172 (sc == rkc2) &&
173 (sc == d2) &&
174 (rc == s2) &&
175 (rc == r2) &&
176 (rc == sc2) &&
177 (rc == rc2) &&
178 (rc == rk2) &&
179 (rc == rkc2) &&
180 (rc == d2) &&
181 (rk == s2) &&
182 (rk == r2) &&
183 (rk == sc2) &&
184 (rk == rc2) &&
185 (rk == rk2) &&
186 (rk == rkc2) &&
187 (rk == d2) &&
188 (rkc == s2) &&
189 (rkc == r2) &&
190 (rkc == sc2) &&
191 (rkc == rc2) &&
192 (rkc == rk2) &&
193 (rkc == rkc2) &&
194 (rkc == d2) &&
195 (d == s2) &&
196 (d == r2) &&
197 (d == sc2) &&
198 (d == rc2) &&
199 (d == rk2) &&
200 (d == rkc2) &&
201 (d == d2) &&
202 #endif
203 PR_TRUE));