Bug 1313471 - Part 2: Convert TestCOMPtrEq to a gtest. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Fri, 04 Nov 2016 16:22:29 -0700
changeset 321070 67374493c1533524c1da22f40771b5f8da2c26be
parent 321069 0ce11eb36fe5448240b1ed91eb969fc9e0960140
child 321071 f0358531f775aef1892c0661dbd306fcfd138e74
push id83515
push usererahm@mozilla.com
push dateFri, 04 Nov 2016 23:22:35 +0000
treeherdermozilla-inbound@67374493c153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1313471
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1313471 - Part 2: Convert TestCOMPtrEq to a gtest. r=froydnj MozReview-Commit-ID: GifbCK1zzxh
testing/cppunittest.ini
xpcom/tests/TestCOMPtrEq.cpp
xpcom/tests/gtest/TestCOMPtrEq.cpp
xpcom/tests/gtest/moz.build
xpcom/tests/moz.build
--- a/testing/cppunittest.ini
+++ b/testing/cppunittest.ini
@@ -6,17 +6,16 @@
 [TestAudioBuffers]
 skip-if = os == 'b2g'  # Bug 1062937
 [TestAudioMixer]
 [TestBinarySearch]
 [TestBind]
 [TestBloomFilter]
 [TestCOM]
 skip-if = os != 'win'
-[TestCOMPtrEq]
 [TestCSPParser]
 skip-if = os == 'b2g' || (os == 'android' && debug) # Bug 1054246
 [TestCasting]
 [TestCeilingFloor]
 [TestCertDB]
 [TestCheckedInt]
 [TestCookie]
 [TestCountPopulation]
rename from xpcom/tests/TestCOMPtrEq.cpp
rename to xpcom/tests/gtest/TestCOMPtrEq.cpp
--- a/xpcom/tests/TestCOMPtrEq.cpp
+++ b/xpcom/tests/gtest/TestCOMPtrEq.cpp
@@ -4,78 +4,76 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This attempts to test all the possible variations of |operator==|
  * used with |nsCOMPtr|s.
  */
 
 #include "nsCOMPtr.h"
+#include "gtest/gtest.h"
 
 #define NS_ICOMPTREQTESTFOO_IID \
 {0x8eb5bbef, 0xd1a3, 0x4659, \
   {0x9c, 0xf6, 0xfd, 0xf3, 0xe4, 0xd2, 0x00, 0x0e}}
 
 class nsICOMPtrEqTestFoo : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMPTREQTESTFOO_IID)
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsICOMPtrEqTestFoo, NS_ICOMPTREQTESTFOO_IID)
 
-int
-main()
+TEST(COMPtrEq, NullEquality)
 {
   nsCOMPtr<nsICOMPtrEqTestFoo> s;
-  nsICOMPtrEqTestFoo* r = 0;
+  nsICOMPtrEqTestFoo* r = nullptr;
   const nsCOMPtr<nsICOMPtrEqTestFoo> sc;
-  const nsICOMPtrEqTestFoo* rc = 0;
-  nsICOMPtrEqTestFoo* const rk = 0;
-  const nsICOMPtrEqTestFoo* const rkc = 0;
+  const nsICOMPtrEqTestFoo* rc = nullptr;
+  nsICOMPtrEqTestFoo* const rk = nullptr;
+  const nsICOMPtrEqTestFoo* const rkc = nullptr;
   nsICOMPtrEqTestFoo* d = s;
 
-  return (!(true &&
-        (s == s) &&
-        (s == r) &&
-        (s == sc) &&
-        (s == rc) &&
-        (s == rk) &&
-        (s == rkc) &&
-        (s == d) &&
-        (r == s) &&
-        (r == sc) &&
-        (r == rc) &&
-        (r == rk) &&
-        (r == rkc) &&
-        (r == d) &&
-        (sc == s) &&
-        (sc == r) &&
-        (sc == sc) &&
-        (sc == rc) &&
-        (sc == rk) &&
-        (sc == rkc) &&
-        (sc == d) &&
-        (rc == s) &&
-        (rc == r) &&
-        (rc == sc) &&
-        (rc == rk) &&
-        (rc == rkc) &&
-        (rc == d) &&
-        (rk == s) &&
-        (rk == r) &&
-        (rk == sc) &&
-        (rk == rc) &&
-        (rk == rkc) &&
-        (rk == d) &&
-        (rkc == s) &&
-        (rkc == r) &&
-        (rkc == sc) &&
-        (rkc == rc) &&
-        (rkc == rk) &&
-        (rkc == d) &&
-        (d == s) &&
-        (d == r) &&
-        (d == sc) &&
-        (d == rc) &&
-        (d == rk) &&
-        (d == rkc) &&
-        true));
+  ASSERT_EQ(s, s);
+  ASSERT_EQ(s, r);
+  ASSERT_EQ(s, sc);
+  ASSERT_EQ(s, rc);
+  ASSERT_EQ(s, rk);
+  ASSERT_EQ(s, rkc);
+  ASSERT_EQ(s, d);
+  ASSERT_EQ(r, s);
+  ASSERT_EQ(r, sc);
+  ASSERT_EQ(r, rc);
+  ASSERT_EQ(r, rk);
+  ASSERT_EQ(r, rkc);
+  ASSERT_EQ(r, d);
+  ASSERT_EQ(sc, s);
+  ASSERT_EQ(sc, r);
+  ASSERT_EQ(sc, sc);
+  ASSERT_EQ(sc, rc);
+  ASSERT_EQ(sc, rk);
+  ASSERT_EQ(sc, rkc);
+  ASSERT_EQ(sc, d);
+  ASSERT_EQ(rc, s);
+  ASSERT_EQ(rc, r);
+  ASSERT_EQ(rc, sc);
+  ASSERT_EQ(rc, rk);
+  ASSERT_EQ(rc, rkc);
+  ASSERT_EQ(rc, d);
+  ASSERT_EQ(rk, s);
+  ASSERT_EQ(rk, r);
+  ASSERT_EQ(rk, sc);
+  ASSERT_EQ(rk, rc);
+  ASSERT_EQ(rk, rkc);
+  ASSERT_EQ(rk, d);
+  ASSERT_EQ(rkc, s);
+  ASSERT_EQ(rkc, r);
+  ASSERT_EQ(rkc, sc);
+  ASSERT_EQ(rkc, rc);
+  ASSERT_EQ(rkc, rk);
+  ASSERT_EQ(rkc, d);
+  ASSERT_EQ(d, s);
+  ASSERT_EQ(d, r);
+  ASSERT_EQ(d, sc);
+  ASSERT_EQ(d, rc);
+  ASSERT_EQ(d, rk);
+  ASSERT_EQ(d, rkc);
 }
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -6,16 +6,17 @@
 
 UNIFIED_SOURCES += [
     'Helpers.cpp',
     'TestAtoms.cpp',
     'TestAutoPtr.cpp',
     'TestAutoRef.cpp',
     'TestCloneInputStream.cpp',
     'TestCOMArray.cpp',
+    'TestCOMPtrEq.cpp',
     'TestCRT.cpp',
     'TestEncoding.cpp',
     'TestEscapeURL.cpp',
     'TestExpirationTracker.cpp',
     'TestNSPRLogModulesParser.cpp',
     'TestPipes.cpp',
     'TestPLDHash.cpp',
     'TestPriorityQueue.cpp',
--- a/xpcom/tests/moz.build
+++ b/xpcom/tests/moz.build
@@ -41,17 +41,16 @@ if CONFIG['OS_TARGET'] == 'WINNT':
 if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']:
     GeckoSimplePrograms([
         'TestSTLWrappers',
     ])
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
 
 GeckoCppUnitTests([
-    'TestCOMPtrEq',
     'TestFile',
     'TestHashtables',
     'TestID',
     'TestNsRefPtr',
     'TestObserverArray',
     'TestObserverService',
     'TestStringAPI',
     'TestTArray',