MCPcopy Create free account
hub / github.com/awslabs/llrt / testDecode

Function testDecode

tests/unit/string_decoder.test.ts:17–38  ·  view source on GitHub ↗
(
    encoding: BufferEncoding,
    input: Buffer,
    expected: string,
    singleSequence?: Array<Array<number>>
  )

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

writeMethod · 0.95
endMethod · 0.95
writeSequencesFunction · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected