Bug 823422: Make ipdl C++ unit tests compile again. r=jlebar
authorChris Jones <jones.chris.g@gmail.com>
Thu, 20 Dec 2012 11:54:00 -0800
changeset 125804 487d0f89749b59ae18afb621ec42631929d37f23
parent 125803 8cbe2966ec8a75a0b4cb2975edd9034fe1e6ded5
child 125805 a2e79ebb34af1f130a01a76160a0a88731afa3c7
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs823422
milestone20.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 823422: Make ipdl C++ unit tests compile again. r=jlebar
ipc/ipdl/test/cxx/TestDataStructures.cpp
ipc/ipdl/test/cxx/TestJSON.cpp
--- a/ipc/ipdl/test/cxx/TestDataStructures.cpp
+++ b/ipc/ipdl/test/cxx/TestDataStructures.cpp
@@ -11,17 +11,17 @@ namespace _ipdltest {
 
 static const uint32_t nactors = 10;
 
 #define test_assert(_cond, _msg) \
     if (!(_cond)) fail(_msg)
 
 template<typename T>
 static void
-assert_arrays_equal(InfallibleTArray<T> a, InfallibleTArray<T> b)
+assert_arrays_equal(const InfallibleTArray<T>& a, const InfallibleTArray<T>& b)
 {
     test_assert(a == b, "arrays equal");
 }
 
 inline static TestDataStructuresSub&
 Cast(PTestDataStructuresSubParent* a)
 {
     return *static_cast<TestDataStructuresSub*>(a);
@@ -174,23 +174,23 @@ bool TestDataStructuresParent::RecvTest6
         const InfallibleTArray<IntDoubleArrays>& i1,
         InfallibleTArray<IntDoubleArrays>* o1)
 {
     test_assert(3 == i1.Length(), "wrong length");
 
     IntDoubleArrays id1(i1[0]);
     test_assert(42 == id1.get_int(), "wrong value");
 
-    InfallibleTArray<int> i2a = i1[1].get_ArrayOfint();
+    InfallibleTArray<int> i2a(i1[1].get_ArrayOfint());
     test_assert(3 == i2a.Length(), "wrong length");
     test_assert(1 == i2a[0], "wrong value");
     test_assert(2 == i2a[1], "wrong value");
     test_assert(3 == i2a[2], "wrong value");
 
-    InfallibleTArray<double> i3a = i1[2].get_ArrayOfdouble();
+    InfallibleTArray<double> i3a(i1[2].get_ArrayOfdouble());
     test_assert(3 == i3a.Length(), "wrong length");
     test_assert(1.0 == i3a[0], "wrong value");
     test_assert(2.0 == i3a[1], "wrong value");
     test_assert(3.0 == i3a[2], "wrong value");
 
     o1->AppendElement(id1);
     o1->AppendElement(IntDoubleArrays(i2a));
     o1->AppendElement(IntDoubleArrays(i3a));
@@ -613,18 +613,18 @@ TestDataStructuresChild::Test6()
     i1.AppendElement(IntDoubleArrays(id3));
 
     InfallibleTArray<IntDoubleArrays> o1;
     if (!SendTest6(i1, &o1))
         fail("can't send Test6");
 
     test_assert(3 == o1.Length(), "wrong length");
     IntDoubleArrays od1(o1[0]);
-    InfallibleTArray<int> od2 = o1[1].get_ArrayOfint();
-    InfallibleTArray<double> od3 = o1[2].get_ArrayOfdouble();
+    InfallibleTArray<int> od2(o1[1].get_ArrayOfint());
+    InfallibleTArray<double> od3(o1[2].get_ArrayOfdouble());
 
     test_assert(42 == od1.get_int(), "wrong value");
     assert_arrays_equal(id2, od2);
     assert_arrays_equal(id3, od3);
 
     printf("  passed %s\n", __FUNCTION__);
 }
 
--- a/ipc/ipdl/test/cxx/TestJSON.cpp
+++ b/ipc/ipdl/test/cxx/TestJSON.cpp
@@ -9,25 +9,22 @@ namespace mozilla {
 namespace _ipdltest {
 
 static nsString
 String(const char* const str)
 {
     return NS_ConvertUTF8toUTF16(str);
 }
 
-static InfallibleTArray<JSONVariant>
-Array123()
+static void
+Array123(InfallibleTArray<JSONVariant>& a123)
 {
-    InfallibleTArray<JSONVariant> a123;
     a123.AppendElement(1);  a123.AppendElement(2);  a123.AppendElement(3);
 
     test_assert(a123 == a123, "operator== is broken");
-
-    return a123;
 }
 
 template<class HandleT>
 JSONVariant
 MakeTestVariant(HandleT* handle)
 {
     // In JS syntax:
     //
@@ -50,26 +47,30 @@ MakeTestVariant(HandleT* handle)
     outer.AppendElement(void_t());
     outer.AppendElement(null_t());
     outer.AppendElement(true);
     outer.AppendElement(1.25);
     outer.AppendElement(String("test string"));
 
     outer.AppendElement(handle);
 
-    outer.AppendElement(Array123());
+    InfallibleTArray<JSONVariant> tmp;
+    Array123(tmp);
+    outer.AppendElement(tmp);
 
     InfallibleTArray<KeyValue> obj;
     obj.AppendElement(KeyValue(String("undefined"), void_t()));
     obj.AppendElement(KeyValue(String("null"), null_t()));
     obj.AppendElement(KeyValue(String("true"), true));
     obj.AppendElement(KeyValue(String("1.25"), 1.25));
     obj.AppendElement(KeyValue(String("string"), String("value")));
     obj.AppendElement(KeyValue(String("handle"), handle));
-    obj.AppendElement(KeyValue(String("array"), Array123()));
+    InfallibleTArray<JSONVariant> tmp2;
+    Array123(tmp2);
+    obj.AppendElement(KeyValue(String("array"), tmp2));
 
     outer.AppendElement(obj);
 
     test_assert(outer == outer, "operator== is broken");
 
     return JSONVariant(outer);
 }