it("SlowBuffer is supported", function() { var SlowBuffer = require('buffer').SlowBuffer; var buf = new SlowBuffer(10); assert.equal(buf.write("hello world", "windows-1251"), 10); assert.equal(buf.toString(), "hello worl"); assert.equal(buf.write("hello world", 2, "windows-1251"), 8); assert.equal(buf.toString(), "hehello wo"); assert.equal(buf.write("abcde abcde", 3, 4, "windows-1251"), 4); assert.equal(buf.toString(), "hehabcd wo"); assert.equal(buf.write("活洽派洶洛泵洹洧", 1, "big5"), 9); assert.equal(buf.toString('big5'), "h活洽派洶�"); // TODO: the following line is more correct. //assert.equal(buf.toString('big5'), "h活洽派洶o"); // TODO: Set _charsWritten. });
['base64','binary','ucs2','utf8','ascii'].forEach(function(encoding) { var buf = new SlowBuffer(0); buf.write('', encoding); });
['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { var b = new SlowBuffer(10); b.write('あいうえお', encoding); assert.equal(b.toString(encoding), 'あいうえお'); });
assert.doesNotThrow(function () { var slow = new SlowBuffer(1); assert(slow.write('', Buffer.poolSize * 10) === 0); var fast = new Buffer(1); assert(fast.write('', Buffer.poolSize * 10) === 0); });