Unit test for bug 365345
authorsmontagu@smontagu.org
Wed, 09 May 2007 04:36:06 -0700
changeset 1311 2f160c6425fedc00e2ac3c63591d6b625d5a3141
parent 1310 a55e99e20025e80555a93a9e3f4ac8755ebd998b
child 1312 0a1cecca4bc1d9866bd94e651f9caa59eed7e5cd
push idunknown
push userunknown
push dateunknown
bugs365345
milestone1.9a5pre
Unit test for bug 365345
intl/uconv/tests/unit/test_bug365345.js
new file mode 100644
--- /dev/null
+++ b/intl/uconv/tests/unit/test_bug365345.js
@@ -0,0 +1,52 @@
+/* Tests conversion of unrepresented characters that should be transliterated
+ * to spaces (bug 365345), and some others from transliterate.properties while
+ * I'm here
+ */
+
+const inSpace = "Hello Space";
+const inEnSpace = "Hello\u2002EnSpace";
+const inEmSpace = "Hello\u2003EmSpace";
+const inEuro = "Hello\u20ACEuro";
+const inTamil1000 = "Hello\u0BF2Tamil1000";
+const inMonospace9 = "Hello\ud835\udfffMonospace9";
+    
+const expectedSpace = "Hello Space";
+const expectedEnSpace = "Hello EnSpace";
+const expectedEmSpace = "Hello EmSpace";
+const expectedEuro = "HelloEUREuro";
+const expectedTamil1000 = "Hello[1000]Tamil1000";
+const expectedMonospace9 = "Hello9Monospace9";
+
+const EntityAfterCharsetConv = 512;
+const transliterate = 8;
+
+const charset = "ISO-8859-1";
+    
+function run_test() {
+    var SaveAsCharset =
+	Components.Constructor("@mozilla.org/intl/saveascharset;1",
+			       "nsISaveAsCharset",
+			       "Init");
+
+    var converter = new SaveAsCharset(charset,
+				      EntityAfterCharsetConv, 
+				      transliterate);
+
+    var outSpace = converter.Convert(inSpace);
+    do_check_eq(outSpace, expectedSpace);
+
+    var outEnSpace = converter.Convert(inEnSpace);
+    do_check_eq(outEnSpace, expectedEnSpace);
+
+    var outEmSpace = converter.Convert(inEmSpace);
+    do_check_eq(outEmSpace, expectedEmSpace);
+
+    var outEuro = converter.Convert(inEuro);
+    do_check_eq(outEuro, expectedEuro);
+
+    var outTamil1000 = converter.Convert(inTamil1000);
+    do_check_eq(outTamil1000, expectedTamil1000);
+
+    var outMonospace9 = converter.Convert(inMonospace9);
+    do_check_eq(outMonospace9, expectedMonospace9);
+}