From 095ac43d808a3f8a063e2af685a78fb381db2169 Mon Sep 17 00:00:00 2001 From: Jesse Tane Date: Tue, 11 Aug 2015 00:43:36 -0400 Subject: [PATCH] add failing test for missing replacement characters in the surrogate pair range --- test/to-string.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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() +}) -- 2.34.1