(
encoding: BufferEncoding,
input: Buffer,
expected: string,
singleSequence?: Array<Array<number>>
)
| 15 | // singleSequence allows for easy debugging of a specific sequence which is |
| 16 | // useful in case of testDecode failures. |
| 17 | function testDecode( |
| 18 | encoding: BufferEncoding, |
| 19 | input: Buffer, |
| 20 | expected: string, |
| 21 | singleSequence?: Array<Array<number>> |
| 22 | ) { |
| 23 | let sequences; |
| 24 | if (!singleSequence) { |
| 25 | sequences = writeSequences(input.length); |
| 26 | } else { |
| 27 | sequences = [singleSequence]; |
| 28 | } |
| 29 | sequences.forEach((sequence) => { |
| 30 | const decoder = new StringDecoder(encoding); |
| 31 | let output = ""; |
| 32 | sequence.forEach((write) => { |
| 33 | output += decoder.write(input.slice(write[0], write[1])); |
| 34 | }); |
| 35 | output += decoder.end(); |
| 36 | expect(output).toEqual(expected); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | // writeSequences returns an array of arrays that describes all possible ways a |
| 41 | // buffer of the given length could be split up and passed to sequential write |
no test coverage detected