Bug 937056 - Fix tests in c-c. r=hsivonen

This commit is contained in:
Mark Banner 2014-04-23 04:30:00 -04:00
Родитель 9bb15d9249
Коммит 17d5c7c2e1
4 изменённых файлов: 81 добавлений и 17 удалений

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

@ -16,4 +16,4 @@ MSVC_ENABLE_PGO = True
FINAL_LIBRARY = 'mail'
# Tests need more attention before they can be enabled.
# TEST_DIRS += ['test']
TEST_DIRS += ['test']

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

@ -1,16 +0,0 @@
# 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/.
DEPTH = ../../..
topsrcdir = ../../..
srcdir = .
VPATH = .
relativesrcdir = mailnews/intl/test
include $(DEPTH)/config/autoconf.mk
XPCSHELL_TESTS = unit
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,76 @@
const Ci = Components.interfaces;
const Cc = Components.classes;
const CC = Components.Constructor;
function CreateScriptableConverter()
{
var ScriptableUnicodeConverter =
CC("@mozilla.org/intl/scriptableunicodeconverter",
"nsIScriptableUnicodeConverter");
return new ScriptableUnicodeConverter();
}
function checkDecode(converter, charset, inText, expectedText)
{
try {
converter.charset = charset;
} catch(e) {
converter.charset = "iso-8859-1";
}
dump("testing decoding from " + charset + " to Unicode.\n");
try {
var outText = converter.ConvertToUnicode(inText) + converter.Finish();
} catch(e) {
outText = "\ufffd";
}
do_check_eq(outText, expectedText);
}
function checkEncode(converter, charset, inText, expectedText)
{
try {
converter.charset = charset;
} catch(e) {
converter.charset = "iso-8859-1";
}
dump("testing encoding from Unicode to " + charset + "\n");
var outText = converter.ConvertFromUnicode(inText) + converter.Finish();
do_check_eq(outText, expectedText);
}
function testDecodeAliases()
{
var converter = CreateScriptableConverter();
for (var i = 0; i < aliases.length; ++i) {
checkDecode(converter, aliases[i], inString, expectedString);
}
}
function testEncodeAliases()
{
var converter = CreateScriptableConverter();
for (var i = 0; i < aliases.length; ++i) {
checkEncode(converter, aliases[i], inString, expectedString);
}
}
function testDecodeAliasesInternal()
{
var converter = CreateScriptableConverter();
converter.isInternal = true;
for (var i = 0; i < aliases.length; ++i) {
checkDecode(converter, aliases[i], inString, expectedString);
}
}
function testEncodeAliasesInternal()
{
var converter = CreateScriptableConverter();
converter.isInternal = true;
for (var i = 0; i < aliases.length; ++i) {
checkEncode(converter, aliases[i], inString, expectedString);
}
}

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

@ -1,4 +1,8 @@
[DEFAULT]
head =
tail =
support-files =
CharsetConversionTests.js
[test_decode_utf-7.js]
[test_decode_utf-7_internal.js]