deno.land / std@0.224.0 / streams / text_delimiter_stream_test.ts

text_delimiter_stream_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { TextDelimiterStream } from "./text_delimiter_stream.ts";import { testTransformStream } from "./_test_common.ts";
Deno.test("TextDelimiterStream handles discard", async () => { const delimStream = new TextDelimiterStream("foo", { disposition: "discard", }); const inputs = [ "qwertzu", // no delimiter "iopasdfoomnbvc", // one delimiter in the middle "xylkjhfoogfdsapfoooiuzt", // two separate delimiters "euoifoofooaueiou", // two consecutive delimiters "rewq098765432fo", // split delimiter (1/2) "o349012i491290", // split delimiter (2/2) ]; const outputs = [ "qwertzuiopasd", "mnbvcxylkjh", "gfdsap", "oiuzteuoi", "", "aueiourewq098765432", "349012i491290", ];
await testTransformStream(delimStream, inputs, outputs);});
Deno.test("TextDelimiterStream handles suffix", async () => { const delimStream = new TextDelimiterStream("foo", { disposition: "suffix", }); const inputs = [ "qwertzu", // no delimiter "iopasdfoomnbvc", // one delimiter in the middle "xylkjhfoogfdsapfoooiuzt", // two separate delimiters "euoifoofooaueiou", // two consecutive delimiters "rewq098765432fo", // split delimiter (1/2) "o349012i491290", // split delimiter (2/2) ]; const outputs = [ "qwertzuiopasdfoo", "mnbvcxylkjhfoo", "gfdsapfoo", "oiuzteuoifoo", "foo", "aueiourewq098765432foo", "349012i491290", ];
await testTransformStream(delimStream, inputs, outputs);});
Deno.test("TextDelimiterStream handles prefix", async () => { const delimStream = new TextDelimiterStream("foo", { disposition: "prefix", }); const inputs = [ "qwertzu", // no delimiter "iopasdfoomnbvc", // one delimiter in the middle "xylkjhfoogfdsapfoooiuzt", // two separate delimiters "euoifoofooaueiou", // two consecutive delimiters "rewq098765432fo", // split delimiter (1/2) "o349012i491290", // split delimiter (2/2) ]; const outputs = [ "qwertzuiopasd", "foomnbvcxylkjh", "foogfdsap", "foooiuzteuoi", "foo", "fooaueiourewq098765432", "foo349012i491290", ];
await testTransformStream(delimStream, inputs, outputs);});
std

Version Info

Tagged at
6 months ago