| 191 | self.assertEqual(ostream.getvalue(), self.tstring[0]) |
| 192 | |
| 193 | def test_incrementaldecoder(self): |
| 194 | UTF8Writer = codecs.getwriter('utf-8') |
| 195 | for sizehint in [None, -1] + list(range(1, 33)) + \ |
| 196 | [64, 128, 256, 512, 1024]: |
| 197 | istream = BytesIO(self.tstring[0]) |
| 198 | ostream = UTF8Writer(BytesIO()) |
| 199 | decoder = self.incrementaldecoder() |
| 200 | while 1: |
| 201 | data = istream.read(sizehint) |
| 202 | if not data: |
| 203 | break |
| 204 | else: |
| 205 | u = decoder.decode(data) |
| 206 | ostream.write(u) |
| 207 | |
| 208 | self.assertEqual(ostream.getvalue(), self.tstring[1]) |
| 209 | |
| 210 | def test_incrementalencoder_error_callback(self): |
| 211 | inv = self.unmappedunicode |