Bug 1313474 - Convert XPCOM test TestID to a gtest. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Fri, 04 Nov 2016 16:23:08 -0700
changeset 321075 372a2270744cba727c5422528e7adf80655c3503
parent 321074 c5d8066cf8729cac7ec8d0bcec1c9c7d47c3242c
child 321076 52f7c6687d175c0d37359a02a504dfdf62e80b6b
push id83518
push usererahm@mozilla.com
push dateFri, 04 Nov 2016 23:23:15 +0000
treeherdermozilla-inbound@372a2270744c [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'