public function testCharactersCanBeReadAsByteArrays()
{
$reader = $this->_getReader();
$factory = $this->_getFactory($reader);
$stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8');
$reader->shouldReceive('getInitialByteSize')->zeroOrMoreTimes()->andReturn(1);
//String
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
//Stream
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd0), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
$reader->shouldReceive('validateByteSequence')->once()->with(array(0xd1), 1)->andReturn(1);
$stream->importString(pack('C*', 0xd0, 0x94, 0xd0, 0xb6, 0xd0, 0xbe));
$stream->write(pack('C*', 0xd0, 0xbb, 0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b, 0xd1, 0x85));
$this->assertEquals(array(0xd0, 0x94), $stream->readBytes(1));
$this->assertEquals(array(0xd0, 0xb6, 0xd0, 0xbe), $stream->readBytes(2));
$this->assertEquals(array(0xd0, 0xbb), $stream->readBytes(1));
$this->assertEquals(array(0xd1, 0x8e, 0xd0, 0xb1, 0xd1, 0x8b), $stream->readBytes(3));
$this->assertEquals(array(0xd1, 0x85), $stream->readBytes(1));
$this->assertSame(false, $stream->readBytes(1));
}