Back to index

lightning-sunbird  0.9+nobinonly
TestCOMPtrEq.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is TestCOMPtrEq.cpp.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * L. David Baron.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   L. David Baron <dbaron@dbaron.org> (original author)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00049 #include "nsCOMPtr.h"
00050 
00051   // Don't test these now, since some of them won't work and it's
00052   // not clear whether they should (see above).
00053 #undef NSCAP_EQTEST_TEST_ACROSS_TYPES
00054 
00055 #define NS_ICOMPTREQTESTFOO_IID \
00056   {0x8eb5bbef, 0xd1a3, 0x4659, \
00057     {0x9c, 0xf6, 0xfd, 0xf3, 0xe4, 0xd2, 0x00, 0x0e}}
00058 
00059 class nsICOMPtrEqTestFoo : public nsISupports {
00060   public:
00061     NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO_IID)
00062 };
00063 
00064 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
00065 
00066 #define NS_ICOMPTREQTESTFOO2_IID \
00067   {0x6516387b, 0x36c5, 0x4036, \
00068     {0x82, 0xc9, 0xa7, 0x4d, 0xd9, 0xe5, 0x92, 0x2f}}
00069 
00070 class nsICOMPtrEqTestFoo2 : public nsISupports {
00071   public:
00072     NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO2_IID)
00073 };
00074 
00075 #endif
00076 
00077 int
00078 main()
00079   {
00080     nsCOMPtr<nsICOMPtrEqTestFoo> s;
00081     nsICOMPtrEqTestFoo* r = 0;
00082     const nsCOMPtr<nsICOMPtrEqTestFoo> sc;
00083     const nsICOMPtrEqTestFoo* rc = 0;
00084     nsICOMPtrEqTestFoo* const rk = 0;
00085     const nsICOMPtrEqTestFoo* const rkc = 0;
00086     nsDerivedSafe<nsICOMPtrEqTestFoo>* d = s.get();
00087     
00088 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
00089     nsCOMPtr<nsICOMPtrEqTestFoo2> s2;
00090     nsICOMPtrEqTestFoo2* r2 = 0;
00091     const nsCOMPtr<nsICOMPtrEqTestFoo2> sc2;
00092     const nsICOMPtrEqTestFoo2* rc2 = 0;
00093     nsICOMPtrEqTestFoo2* const rk2 = 0;
00094     const nsICOMPtrEqTestFoo2* const rkc2 = 0;
00095     nsDerivedSafe<nsICOMPtrEqTestFoo2>* d2 = s2.get();
00096 #endif
00097 
00098     return (!(PR_TRUE &&
00099               (s == s) &&
00100               (s == r) &&
00101               (s == sc) &&
00102               (s == rc) &&
00103               (s == rk) &&
00104               (s == rkc) &&
00105               (s == d) &&
00106               (r == s) &&
00107               (r == r) &&
00108               (r == sc) &&
00109               (r == rc) &&
00110               (r == rk) &&
00111               (r == rkc) &&
00112               (r == d) &&
00113               (sc == s) &&
00114               (sc == r) &&
00115               (sc == sc) &&
00116               (sc == rc) &&
00117               (sc == rk) &&
00118               (sc == rkc) &&
00119               (sc == d) &&
00120               (rc == s) &&
00121               (rc == r) &&
00122               (rc == sc) &&
00123               (rc == rc) &&
00124               (rc == rk) &&
00125               (rc == rkc) &&
00126               (rc == d) &&
00127               (rk == s) &&
00128               (rk == r) &&
00129               (rk == sc) &&
00130               (rk == rc) &&
00131               (rk == rk) &&
00132               (rk == rkc) &&
00133               (rk == d) &&
00134               (rkc == s) &&
00135               (rkc == r) &&
00136               (rkc == sc) &&
00137               (rkc == rc) &&
00138               (rkc == rk) &&
00139               (rkc == rkc) &&
00140               (rkc == d) &&
00141               (d == s) &&
00142               (d == r) &&
00143               (d == sc) &&
00144               (d == rc) &&
00145               (d == rk) &&
00146               (d == rkc) &&
00147               (d == d) &&
00148 #ifdef NSCAP_EQTEST_TEST_ACROSS_TYPES
00149               (s == s2) &&
00150               (s == r2) &&
00151               (s == sc2) &&
00152               (s == rc2) &&
00153               (s == rk2) &&
00154               (s == rkc2) &&
00155               (s == d2) &&
00156               (r == s2) &&
00157               (r == r2) &&
00158               (r == sc2) &&
00159               (r == rc2) &&
00160               (r == rk2) &&
00161               (r == rkc2) &&
00162               (r == d2) &&
00163               (sc == s2) &&
00164               (sc == r2) &&
00165               (sc == sc2) &&
00166               (sc == rc2) &&
00167               (sc == rk2) &&
00168               (sc == rkc2) &&
00169               (sc == d2) &&
00170               (rc == s2) &&
00171               (rc == r2) &&
00172               (rc == sc2) &&
00173               (rc == rc2) &&
00174               (rc == rk2) &&
00175               (rc == rkc2) &&
00176               (rc == d2) &&
00177               (rk == s2) &&
00178               (rk == r2) &&
00179               (rk == sc2) &&
00180               (rk == rc2) &&
00181               (rk == rk2) &&
00182               (rk == rkc2) &&
00183               (rk == d2) &&
00184               (rkc == s2) &&
00185               (rkc == r2) &&
00186               (rkc == sc2) &&
00187               (rkc == rc2) &&
00188               (rkc == rk2) &&
00189               (rkc == rkc2) &&
00190               (rkc == d2) &&
00191               (d == s2) &&
00192               (d == r2) &&
00193               (d == sc2) &&
00194               (d == rc2) &&
00195               (d == rk2) &&
00196               (d == rkc2) &&
00197               (d == d2) &&
00198 #endif
00199               PR_TRUE));
00200   }