From: Jesse Tane Date: Tue, 11 Aug 2015 04:43:36 +0000 (-0400) Subject: add failing test for missing replacement characters in the surrogate pair range X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=095ac43d808a3f8a063e2af685a78fb381db2169;p=buffer.git add failing test for missing replacement characters in the surrogate pair range --- diff --git a/test/to-string.js b/test/to-string.js index 662f8c9..8fd9db1 100644 --- a/test/to-string.js +++ b/test/to-string.js @@ -199,3 +199,27 @@ test('utf8 replacement chars on 256 random bytes', function (t) { ) t.end() }) + +test('utf8 replacement chars for anything in the surrogate pair range', function (t) { + t.equal( + new B([ 0xED, 0x9F, 0xBF ]).toString(), + '\uD7FF' + ) + t.equal( + new B([ 0xED, 0xA0, 0x80 ]).toString(), + '\uFFFD\uFFFD\uFFFD' + ) + t.equal( + new B([ 0xED, 0xBE, 0x8B ]).toString(), + '\uFFFD\uFFFD\uFFFD' + ) + t.equal( + new B([ 0xED, 0xBF, 0xBF ]).toString(), + '\uFFFD\uFFFD\uFFFD' + ) + t.equal( + new B([ 0xEE, 0x80, 0x80 ]).toString(), + '\uE000' + ) + t.end() +})