(encoding, buf)
| 385 | } |
| 386 | |
| 387 | function testBuf(encoding, buf) { |
| 388 | // Write one byte at a time. |
| 389 | let s = new StringDecoder(encoding); |
| 390 | let res1 = ''; |
| 391 | for (let i = 0; i < buf.length; i++) { |
| 392 | res1 += s.write(buf.slice(i, i + 1)); |
| 393 | } |
| 394 | res1 += s.end(); |
| 395 | |
| 396 | // Write the whole buffer at once. |
| 397 | let res2 = ''; |
| 398 | s = new StringDecoder(encoding); |
| 399 | res2 += s.write(buf); |
| 400 | res2 += s.end(); |
| 401 | |
| 402 | // .toString() on the buffer |
| 403 | const res3 = buf.toString(encoding); |
| 404 | |
| 405 | // One byte at a time should match toString |
| 406 | strictEqual(res1, res3); |
| 407 | // All bytes at once should match toString |
| 408 | strictEqual(res2, res3); |
| 409 | } |
| 410 | |
| 411 | function testEnd(encoding, incomplete, next, expected) { |
| 412 | let res = ''; |
no test coverage detected