diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-05-16 15:00:33 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-05-16 15:01:33 -0700 |
commit | 103a450d3a6ca5281a5ac6579dfecbebe748f745 (patch) | |
tree | 977e08139087715782fce7b187e1fcd2daecfacf /test | |
parent | 249361cab798420679ae7d3dee3b33f04c97cb35 (diff) | |
download | node-new-103a450d3a6ca5281a5ac6579dfecbebe748f745.tar.gz |
Remove 'binary' encoding assert - add tests
Don't write large characters to buffers with binary encoding. You will be
silently injured.
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-buffer.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 11bc58b165..1aa4611010 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -505,3 +505,18 @@ assert.equal(0x6f, z[1]); var b = new SlowBuffer(10); b.write('あいうえお', 'ucs2'); assert.equal(b.toString('ucs2'), 'あいうえお'); + +// Binary encoding should write only one byte per character. +var b = Buffer([0xde, 0xad, 0xbe, 0xef]); +var s = String.fromCharCode(0xffff); +b.write(s, 0, 'binary') +assert.equal(0xff, b[0]); +assert.equal(0xad, b[1]); +assert.equal(0xbe, b[2]); +assert.equal(0xef, b[3]); +s = String.fromCharCode(0xaaee); +b.write(s, 0, 'binary') +assert.equal(0xee, b[0]); +assert.equal(0xad, b[1]); +assert.equal(0xbe, b[2]); +assert.equal(0xef, b[3]); |