1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Index: node-string-width/test.js
===================================================================
--- node-string-width.orig/test.js
+++ node-string-width/test.js
@@ -19,3 +19,34 @@ test('ignores control characters', funct
assert.equal(m(String.fromCharCode(159)), 0);
assert.equal(m('\u001b'), 0);
});
+
+test('test zero-width non-joiner (ZWNJ) unicode codepoints', function() {
+ // all samples from https://en.wikipedia.org/wiki/Zero-width_non-joiner
+ assert.equal(m('می\u200cخواه'), 6);
+ assert.equal(m('עֲו\u200cנֹת'), 4);
+ assert.equal(m('Auf\u200clage'), 7);
+ assert.equal(m('Brot\u200czeit'), 8);
+ assert.equal(m('deaf\u200cly'), 6);
+ assert.equal(m('श्रीमान्\u200cको'), 8);
+});
+
+test('test zero-width joiner (ZWJ) unicode codepoints', function() {
+ // all samples from https://en.wikipedia.org/wiki/Zero-width_joiner
+ assert.equal(m('क्'), 1);
+ assert.equal(m('क्'), 1);
+ assert.equal(m('क्ष'), 2);
+ assert.equal(m('क्ष'), 2);
+ assert.equal(m('ನ್'), 1);
+ assert.equal(m('ನ್ನ'), 2);
+ assert.equal(m('ನ್ನ'), 2);
+ assert.equal(m('ರ್ಕ'), 2);
+ assert.equal(m('ರ್ಕ'), 2);
+ assert.equal(m('ണ്'), 1);
+ assert.equal(m('ന്'), 1);
+ assert.equal(m('ര്'), 1);
+ assert.equal(m('ല്'), 1);
+ assert.equal(m('ള്'), 1);
+ // random samples from http://unicode.org/emoji/charts/emoji-zwj-sequences.html
+ assert.equal(m('\u{1F468}\u{200D}\u{1F469}\u{200D}\u{1F466}'), 3); // family: man, woman, boy
+ assert.equal(m('\u{1F469}\u{200D}\u{2764}\u{FE0F}\u{200D}\u{1F48B}\u{200D}\u{1F468}'), 4); // kiss: woman, man
+});
|