]> zoso.dev Git - buffer.git/commitdiff
add failing test for missing replacement characters in the surrogate pair range
authorJesse Tane <jesse.tane@gmail.com>
Tue, 11 Aug 2015 04:43:36 +0000 (00:43 -0400)
committerJesse Tane <jesse.tane@gmail.com>
Tue, 11 Aug 2015 05:39:45 +0000 (01:39 -0400)
test/to-string.js

index 662f8c9e1c8ebc928ae1e71eed36f6c50c4032c9..8fd9db1fd3087537d3d3d965302dbfdfd2f58bbb 100644 (file)
@@ -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()
+})