Bug 1313474 - Convert XPCOM test TestID to a gtest. r=froydnj

MozReview-Commit-ID: 7rLi2Y9lYEI

--HG--
rename : xpcom/tests/TestID.cpp => xpcom/tests/gtest/TestID.cpp
This commit is contained in:
Eric Rahm 2016-11-03 17:56:02 -07:00
Родитель 2f5b6bf1e3
Коммит 6da13d0163
4 изменённых файлов: 12 добавлений и 20 удалений

Просмотреть файл

@ -33,7 +33,6 @@ skip-if = os != 'win'
[TestFloatingPoint]
[TestFunction]
[TestGetURL]
[TestID]
[TestIntegerPrintfMacros]
[TestIntegerRange]
[TestIsCertBuiltInRoot]

Просмотреть файл

@ -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 <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}",
@ -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);
}
}

Просмотреть файл

@ -17,6 +17,7 @@ UNIFIED_SOURCES += [
'TestEscapeURL.cpp',
'TestExpirationTracker.cpp',
'TestFile.cpp',
'TestID.cpp',
'TestNSPRLogModulesParser.cpp',
'TestPipes.cpp',
'TestPLDHash.cpp',

Просмотреть файл

@ -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',