diff --git a/testing/cppunittest.ini b/testing/cppunittest.ini index 4047270bbefb..ef2e29345a94 100644 --- a/testing/cppunittest.ini +++ b/testing/cppunittest.ini @@ -33,7 +33,6 @@ skip-if = os != 'win' [TestFloatingPoint] [TestFunction] [TestGetURL] -[TestID] [TestIntegerPrintfMacros] [TestIntegerRange] [TestIsCertBuiltInRoot] diff --git a/xpcom/tests/TestID.cpp b/xpcom/tests/gtest/TestID.cpp similarity index 65% rename from xpcom/tests/TestID.cpp rename to xpcom/tests/gtest/TestID.cpp index 2585cf9103c4..cb56554dcd03 100644 --- a/xpcom/tests/TestID.cpp +++ b/xpcom/tests/gtest/TestID.cpp @@ -2,10 +2,11 @@ /* 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 -#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}", @@ -19,25 +20,17 @@ static const char* const ids[] = { }; #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; - } - 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_TRUE(id.Parse(idstr)); - return 0; + char* cp = id.ToString(); + ASSERT_NE(cp, nullptr); + ASSERT_STREQ(cp, ids[4*(i/4) + 3]); + + free(cp); + } } diff --git a/xpcom/tests/gtest/moz.build b/xpcom/tests/gtest/moz.build index ff98d858ec19..4f992c66e195 100644 --- a/xpcom/tests/gtest/moz.build +++ b/xpcom/tests/gtest/moz.build @@ -17,6 +17,7 @@ UNIFIED_SOURCES += [ 'TestEscapeURL.cpp', 'TestExpirationTracker.cpp', 'TestFile.cpp', + 'TestID.cpp', 'TestNSPRLogModulesParser.cpp', 'TestPipes.cpp', 'TestPLDHash.cpp', diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index 5abb01bef31a..da308acbcaa7 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -46,7 +46,6 @@ if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']: XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] GeckoCppUnitTests([ - 'TestID', 'TestNsRefPtr', 'TestObserverArray', 'TestObserverService',