summaryrefslogtreecommitdiffstats
path: root/intl/uconv/tests/unit/test_input_stream.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /intl/uconv/tests/unit/test_input_stream.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/uconv/tests/unit/test_input_stream.js')
-rw-r--r--intl/uconv/tests/unit/test_input_stream.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/intl/uconv/tests/unit/test_input_stream.js b/intl/uconv/tests/unit/test_input_stream.js
new file mode 100644
index 000000000..6ab5fd761
--- /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);
+}