mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
test(cbor): empty string being excluded from expected result (#6106)
This commit is contained in:
parent
123c1fe3c7
commit
39278721df
@ -6,54 +6,48 @@ import { random } from "./_common_test.ts";
|
||||
import { encodeCbor } from "./encode_cbor.ts";
|
||||
import { CborTextEncoderStream } from "./text_encoder_stream.ts";
|
||||
|
||||
Deno.test(
|
||||
"CborTextEncoderStream() correctly encoding",
|
||||
{ ignore: true },
|
||||
async () => {
|
||||
const strings = [
|
||||
"a".repeat(random(0, 24)),
|
||||
"a".repeat(random(24, 2 ** 8)),
|
||||
"a".repeat(random(2 ** 8, 2 ** 10)),
|
||||
];
|
||||
Deno.test("CborTextEncoderStream() correctly encoding", async () => {
|
||||
const strings = [
|
||||
"a".repeat(random(0, 24)),
|
||||
"a".repeat(random(24, 2 ** 8)),
|
||||
"a".repeat(random(2 ** 8, 2 ** 16)),
|
||||
"a".repeat(random(2 ** 16, 2 ** 17)),
|
||||
];
|
||||
|
||||
const expectedOutput = concat([
|
||||
new Uint8Array([0b011_11111]),
|
||||
...strings.filter((x) => x).map((x) => encodeCbor(x)),
|
||||
new Uint8Array([0b111_11111]),
|
||||
]);
|
||||
const expectedOutput = concat([
|
||||
new Uint8Array([0b011_11111]),
|
||||
...strings.map((x) => encodeCbor(x)),
|
||||
new Uint8Array([0b111_11111]),
|
||||
]);
|
||||
|
||||
const actualOutput = concat(
|
||||
await Array.fromAsync(
|
||||
ReadableStream.from(strings).pipeThrough(new CborTextEncoderStream()),
|
||||
),
|
||||
);
|
||||
const actualOutput = concat(
|
||||
await Array.fromAsync(
|
||||
ReadableStream.from(strings).pipeThrough(new CborTextEncoderStream()),
|
||||
),
|
||||
);
|
||||
|
||||
assertEquals(actualOutput, expectedOutput);
|
||||
},
|
||||
);
|
||||
assertEquals(actualOutput, expectedOutput);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
"CborTextEncoderStream.from() correctly encoding",
|
||||
{ ignore: true },
|
||||
async () => {
|
||||
const strings = [
|
||||
"a".repeat(random(0, 24)),
|
||||
"a".repeat(random(24, 2 ** 8)),
|
||||
"a".repeat(random(2 ** 8, 2 ** 10)),
|
||||
];
|
||||
Deno.test("CborTextEncoderStream.from() correctly encoding", async () => {
|
||||
const strings = [
|
||||
"a".repeat(random(0, 24)),
|
||||
"a".repeat(random(24, 2 ** 8)),
|
||||
"a".repeat(random(2 ** 8, 2 ** 16)),
|
||||
"a".repeat(random(2 ** 16, 2 ** 17)),
|
||||
];
|
||||
|
||||
const expectedOutput = concat([
|
||||
new Uint8Array([0b011_11111]),
|
||||
...strings.filter((x) => x).map((x) => encodeCbor(x)),
|
||||
new Uint8Array([0b111_11111]),
|
||||
]);
|
||||
const expectedOutput = concat([
|
||||
new Uint8Array([0b011_11111]),
|
||||
...strings.map((x) => encodeCbor(x)),
|
||||
new Uint8Array([0b111_11111]),
|
||||
]);
|
||||
|
||||
const actualOutput = concat(
|
||||
await Array.fromAsync(
|
||||
CborTextEncoderStream.from(strings).readable,
|
||||
),
|
||||
);
|
||||
const actualOutput = concat(
|
||||
await Array.fromAsync(
|
||||
CborTextEncoderStream.from(strings).readable,
|
||||
),
|
||||
);
|
||||
|
||||
assertEquals(actualOutput, expectedOutput);
|
||||
},
|
||||
);
|
||||
assertEquals(actualOutput, expectedOutput);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user