Bug 1313474 - Convert XPCOM test TestID to a gtest. r=froydnj
☠☠ backed out by 561b87e98ada ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Thu, 03 Nov 2016 17:56:02 -0700
changeset 320853 5b5686e1bcd1a736f9d6f48f29122c8bd5148501
parent 320852 e8d20bdd13d447998e73974644d42787afe2dc43
child 320854 36024a69211724511f461e0cfa1dca435d1a3d66
push id83473
push usererahm@mozilla.com
push dateFri, 04 Nov 2016 00:56:12 +0000
treeherdermozilla-inbound@5b5686e1bcd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1313474
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 1313474 - Convert XPCOM test TestID to a gtest. r=froydnj MozReview-Commit-ID: 7rLi2Y9lYEI
testing/cppunittest.ini
xpcom/tests/TestID.cpp
xpcom/tests/gtest/TestID.cpp
xpcom/tests/gtest/moz.build
xpcom/tests/moz.build
--- a/testing/cppunittest.ini
+++ b/testing/cppunittest.ini
@@ -28,17 +28,16 @@ skip-if = os != 'win'
 [TestEndian]
 [TestEnumeratedArray]
 [TestEnumSet]
 [TestEnumTypeTraits]
 [TestFastBernoulliTrial]
 [TestFloatingPoint]
 [TestFunction]
 [TestGetURL]
-[TestID]
 [TestIntegerPrintfMacros]
 [TestIntegerRange]
 [TestIsCertBuiltInRoot]
 [TestJSONWriter]
 [TestJemalloc]
 [TestLinkedList]
 [TestMacroArgs]
 [TestMacroForEach]
rename from xpcom/tests/TestID.cpp
rename to xpcom/tests/gtest/TestID.cpp
--- a/xpcom/tests/TestID.cpp
+++ b/xpcom/tests/gtest/TestID.cpp
@@ -1,43 +1,36 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include <stdio.h>
-#include "plstr.h"
+
 #include "nsID.h"
 
+#include "gtest/gtest.h"
+
 static const char* const ids[] = {
   "5C347B10-D55C-11D1-89B7-006008911B81",
   "{5C347B10-D55C-11D1-89B7-006008911B81}",
   "5c347b10-d55c-11d1-89b7-006008911b81",
   "{5c347b10-d55c-11d1-89b7-006008911b81}",
 
   "FC347B10-D55C-F1D1-F9B7-006008911B81",
   "{FC347B10-D55C-F1D1-F9B7-006008911B81}",
   "fc347b10-d55c-f1d1-f9b7-006008911b81",
   "{fc347b10-d55c-f1d1-f9b7-006008911b81}",
 };
 #define NUM_IDS ((int) (sizeof(ids) / sizeof(ids[0])))
 
-int main(int argc, char** argv)
+TEST(nsID, StringConversion)
 {
   nsID id;
   for (int i = 0; i < NUM_IDS; i++) {
     const char* idstr = ids[i];
-    if (!id.Parse(idstr)) {
-      fprintf(stderr, "TestID: Parse failed on test #%d\n", i);
-      return -1;
-    }
+    ASSERT_TRUE(id.Parse(idstr));
+
     char* cp = id.ToString();
-    if (nullptr == cp) {
-      fprintf(stderr, "TestID: ToString failed on test #%d\n", i);
-      return -1;
-    }
-    if (0 != PL_strcmp(cp, ids[4*(i/4) + 3])) {
-      fprintf(stderr, "TestID: compare of ToString failed on test #%d\n", i);
-      return -1;
-    }
+    ASSERT_NE(cp, nullptr);
+    ASSERT_STREQ(cp, ids[4*(i/4) + 3]);
+
+    free(cp);
   }
-
-  return 0;
 }
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -12,16 +12,17 @@ UNIFIED_SOURCES += [
     'TestCloneInputStream.cpp',
     'TestCOMArray.cpp',
     'TestCOMPtrEq.cpp',
     'TestCRT.cpp',
     'TestEncoding.cpp',
     'TestEscapeURL.cpp',
     'TestExpirationTracker.cpp',
     'TestFile.cpp',
+    'TestID.cpp',
     'TestNSPRLogModulesParser.cpp',
     'TestPipes.cpp',
     'TestPLDHash.cpp',
     'TestPriorityQueue.cpp',
     'TestSlicedInputStream.cpp',
     'TestSnappyStreams.cpp',
     'TestStateWatching.cpp',
     'TestStorageStream.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([
-    'TestID',
     'TestNsRefPtr',
     'TestObserverArray',
     'TestObserverService',
     'TestStringAPI',
     'TestTArray',
     'TestTextFormatter',
     'TestThreadUtils',
     'TestTimers'