]> zoso.dev Git - buffer.git/commitdiff
add failing test for writing partial utf16 code units
authorJesse Tane <jesse.tane@gmail.com>
Sun, 7 Dec 2014 18:26:34 +0000 (13:26 -0500)
committerJesse Tane <jesse.tane@gmail.com>
Sun, 7 Dec 2014 18:38:00 +0000 (13:38 -0500)
test/utf16.js

index 5462d0eadd1ad4aab43be6cf1e0e9b6ff04518eb..73349a03ec895c90ce91968dda07233315c050c5 100644 (file)
@@ -33,3 +33,12 @@ test('throw on orphaned utf16 surrogate trail code point', function(t) {
   t.equal(err instanceof URIError, true)
   t.end()
 })
+
+test('do not write partial utf16 code units', function(t) {
+  var f = new B([0, 0, 0, 0, 0])
+  t.equal(f.length, 5)
+  var size = f.write('あいうえお', 'utf16le')
+  t.equal(size, 4)
+  t.deepEqual(f, new B([0x42, 0x30, 0x44, 0x30, 0x00]))
+  t.end()
+})