author | Alexander J. Vincent <ajvincent@gmail.com> |
Thu, 17 Oct 2013 16:57:14 -0700 | |
changeset 154924 | bf203d83bb87d0983e2b82fca34734889d080846 |
parent 154923 | f3063fb58ac6fd2ea5f707058b5311c9fbbc6161 |
child 154925 | 43993ae52c1966ac036e79e67d92bac5df1f3be2 |
push id | 25657 |
push user | Ms2ger@gmail.com |
push date | Sun, 17 Nov 2013 13:24:50 +0000 |
treeherder | mozilla-central@0e88f511e067 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smontagu |
bugs | 928185 |
milestone | 28.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
|
intl/uconv/tests/unit/test_input_stream.js | file | annotate | diff | comparison | revisions | |
intl/uconv/tests/unit/xpcshell.ini | file | annotate | diff | comparison | revisions |
new file mode 100644 --- /dev/null +++ b/intl/uconv/tests/unit/test_input_stream.js @@ -0,0 +1,33 @@ +var Ci = Components.interfaces, + Cc = Components.classes, + CC = Components.Constructor; +var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] + .createInstance(Ci.nsIScriptableUnicodeConverter); +converter.charset = "UTF-8"; + +var SIS = CC("@mozilla.org/scriptableinputstream;1", + "nsIScriptableInputStream", + "init"); + +function test_char(code) { + dump("test_char(0x" + code.toString(16) + ")\n"); + var original = String.fromCharCode(code); + var nativeStream = converter.convertToInputStream(original); + var stream = new SIS(nativeStream); + var utf8Result = stream.read(stream.available()); + stream.close(); + var result = converter.ConvertToUnicode(utf8Result); + do_check_eq(escape(original), escape(result)); +} + +function run_test() { + // This is not a very comprehensive test. + for (var i = 0x007f - 2; i <= 0x007f; i++) + test_char(i); + for (i = 0x07ff - 2; i <= 0x07ff; i++) + test_char(i); + for (i = 0x1000 - 2; i <= 0x1000 + 2; i++) + test_char(i); + for (i = 0xe000; i <= 0xe000 + 2; i++) + test_char(i); +}
--- a/intl/uconv/tests/unit/xpcshell.ini +++ b/intl/uconv/tests/unit/xpcshell.ini @@ -150,8 +150,9 @@ support-files = [test_encode_x_mac_hebrew_internal.js] [test_encode_x_mac_icelandic.js] [test_encode_macintosh.js] [test_encode_x_mac_romanian.js] [test_encode_x_mac_turkish.js] [test_encode_x_mac_ukrainian.js] [test_iso2022KR.js] [test_utf8_illegals.js] +[test_input_stream.js]