Bug 1275474 - Part 2. Add nsIUnicodeNormalizer unit test. r?jfkthame
MozReview-Commit-ID: 1vSFQrVrcB3
--- a/intl/unicharutil/tests/moz.build
+++ b/intl/unicharutil/tests/moz.build
@@ -3,9 +3,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/.
SOURCES += [
'NormalizationTest.cpp',
]
+XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
+
FINAL_LIBRARY = 'xul-gtest'
new file mode 100644
--- /dev/null
+++ b/intl/unicharutil/tests/unit/test_unicodenormalizer.js
@@ -0,0 +1,37 @@
+var Ci = Components.interfaces;
+var Cc = Components.classes;
+
+function run_testitem(normalizer, item)
+{
+ let dest = {};
+ normalizer.NormalizeUnicodeNFC(item.src, dest);
+ equal(dest.value, item.nfc);
+
+ normalizer.NormalizeUnicodeNFD(item.src, dest);
+ equal(dest.value, item.nfd);
+
+ normalizer.NormalizeUnicodeNFKC(item.src, dest);
+ equal(dest.value, item.nfkc);
+
+ normalizer.NormalizeUnicodeNFKD(item.src, dest);
+ equal(dest.value, item.nfkd);
+}
+
+function run_test()
+{
+ let normalizer = Cc['@mozilla.org/intl/unicodenormalizer;1'].
+ getService(Ci.nsIUnicodeNormalizer);
+
+ let tests = [
+ { src: "\u339c", nfc: "\u339c", nfd: "\u339c", nfkc: "mm", nfkd: "mm"},
+ { src: "\u30e2\u30b8\u30e9",
+ nfc: "\u30e2\u30b8\u30e9", nfd: "\u30e2\u30b7\u3099\u30e9",
+ nfkc: "\u30e2\u30b8\u30e9", nfkd: "\u30e2\u30b7\u3099\u30e9"},
+ { src: "\u30e2\u30b7\u3099\uff97",
+ nfc: "\u30e2\u30b8\uff97", nfd: "\u30e2\u30b7\u3099\uff97",
+ nfkc: "\u30e2\u30b8\u30e9", nfkd: "\u30e2\u30b7\u3099\u30e9"},
+ ];
+ for (let item of tests) {
+ run_testitem(normalizer, item);
+ }
+}
old mode 100755
new mode 100644
--- a/intl/unicharutil/tests/unit/xpcshell.ini
+++ b/intl/unicharutil/tests/unit/xpcshell.ini
@@ -1,4 +1,6 @@
[DEFAULT]
head =
tail =
skip-if = toolkit == 'gonk'
+
+[test_unicodenormalizer.js]