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