var assert = require('assert')
var saxStream = require('../lib/sax').createStream()
var b = new Buffer('误')
saxStream.on('text', function(text) {
assert.equal(text, b.toString())
})
saxStream.write(new Buffer(''))
saxStream.write(b.slice(0, 1))
saxStream.write(b.slice(1))
saxStream.write(new Buffer(''))
saxStream.write(b.slice(0, 2))
saxStream.write(b.slice(2))
saxStream.write(new Buffer(''))
saxStream.write(b)
saxStream.write(new Buffer(''))
saxStream.write(Buffer.concat([new Buffer(''), b.slice(0, 1)]))
saxStream.end(Buffer.concat([b.slice(1), new Buffer('')]))
var saxStream2 = require('../lib/sax').createStream()
saxStream2.on('text', function(text) {
assert.equal(text, '�')
});
saxStream2.write(new Buffer(''));
saxStream2.write(new Buffer([0xC0]));
saxStream2.write(new Buffer(''));
saxStream2.write(Buffer.concat([new Buffer(''), b.slice(0,1)]));
saxStream2.end();