Bug 1313469 - Part 1: Split out test functions. r=froydnj
☠☠ backed out by 561b87e98ada ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Thu, 03 Nov 2016 17:55:20 -0700
changeset 347684 5364fc8db9b0e29c209f58ea6e06fd9d980436d9
parent 347683 02959aa60196a5d1ea833f1d21052ec50b99058a
child 347685 82bf00ff65052d93ec3dbc337bf223df9bb8b75d
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1313469
milestone52.0a1
Bug 1313469 - Part 1: Split out test functions. r=froydnj This just splits out the test functions, no logic is changed. MozReview-Commit-ID: KjUA9rQ7iOS
xpcom/tests/TestCOMArray.cpp
--- a/xpcom/tests/TestCOMArray.cpp
+++ b/xpcom/tests/TestCOMArray.cpp
@@ -121,24 +121,18 @@ Bar::Release(void)
   if (mRefCnt == 0) {
     mRefCnt = 1; /* stabilize */
     delete this;
     return 0;
   }
   return mRefCnt;
 }
 
-
-int main(int argc, char **argv)
+void Sizing()
 {
-  ScopedXPCOM xpcom("nsCOMArrayTests");
-  if (xpcom.failed()) {
-    return 1;
-  }
-
   int rv = 0;
 
   Array arr;
 
   for (int32_t i = 0; i < 20; ++i) {
     nsCOMPtr<IFoo> foo = new Foo(i);
     arr.AppendObject(foo);
   }
@@ -173,16 +167,20 @@ int main(int argc, char **argv)
   for (int32_t i = 10; i < 30; ++i) {
 	if (arr[i] != nullptr) {
       fail("nsCOMArray elements should be null");
       rv = 1;
 	  break;
     }
   }
 
+}
+
+void ObjectFunctions()
+{
   int32_t base;
   {
     Array2 arr2;
 
     IBar *thirdObject = nullptr,
          *fourthObject = nullptr,
          *fifthObject = nullptr,
          *ninthObject = nullptr;
@@ -254,17 +252,21 @@ int main(int argc, char **argv)
       fail("RemoveObjectsAt should work for removing the last element");
     }
 
     arr2.Clear();
     if (Bar::sReleaseCalled != base + 20) {
       fail("Release called multiple times for Clear");
     }
   }
+}
 
+void ElementFunctions()
+{
+  int32_t base;
   {
     Array2 arr2;
 
     IBar *thirdElement = nullptr,
          *fourthElement = nullptr,
          *fifthElement = nullptr,
          *ninthElement = nullptr;
     for (int32_t i = 0; i < 20; ++i) {
@@ -335,17 +337,21 @@ int main(int argc, char **argv)
       fail("RemoveElementsAt should work for removing the last element");
     }
 
     arr2.Clear();
     if (Bar::sReleaseCalled != base + 20) {
       fail("Release called multiple times for Clear");
     }
   }
+}
 
+void Destructor()
+{
+  int32_t base;
   Bar::sReleaseCalled = 0;
 
   {
     Array2 arr2;
 
     for (int32_t i = 0; i < 20; ++i) {
       nsCOMPtr<IBar> bar  = new Bar(arr2);
       arr2.AppendObject(bar);
@@ -353,11 +359,24 @@ int main(int argc, char **argv)
 
     base = Bar::sReleaseCalled;
 
     // Let arr2 be destroyed
   }
   if (Bar::sReleaseCalled != base + 20) {
     fail("Release called multiple times for nsCOMArray::~nsCOMArray");
   }
+}
 
-  return rv;
+int main(int argc, char **argv)
+{
+  ScopedXPCOM xpcom("nsCOMArrayTests");
+  if (xpcom.failed()) {
+    return 1;
+  }
+
+  Sizing();
+  ObjectFunctions();
+  ElementFunctions();
+  Destructor();
+
+  return 0;
 }