@everyonesoftware/common 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +54 -36
- package/package.json +6 -2
- package/sources/asyncIterator.ts +436 -436
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
- package/sources/asyncResult.ts +95 -95
- package/sources/byteList.ts +201 -201
- package/sources/byteListStream.ts +120 -120
- package/sources/byteReadStream.ts +23 -23
- package/sources/byteWriteStream.ts +15 -15
- package/sources/characterList.ts +194 -194
- package/sources/characterListStream.ts +150 -150
- package/sources/characterReadStream.ts +80 -80
- package/sources/characterReadStreamIterator.ts +127 -127
- package/sources/concatenateIterable.ts +118 -118
- package/sources/concatenateIterator.ts +164 -164
- package/sources/currentProcess.ts +157 -157
- package/sources/dateTime.ts +129 -129
- package/sources/depthFirstSearch.ts +229 -229
- package/sources/flatMapIterable.ts +103 -103
- package/sources/flatMapIterator.ts +151 -151
- package/sources/generator.ts +250 -250
- package/sources/index.ts +1 -1
- package/sources/iterator.ts +480 -480
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
- package/sources/javascriptSetSet.ts +133 -133
- package/sources/listQueue.ts +61 -61
- package/sources/listStack.ts +61 -61
- package/sources/luxonDateTime.ts +108 -108
- package/sources/mapAsyncIterator.ts +140 -140
- package/sources/mutableMap.ts +291 -291
- package/sources/node.ts +36 -36
- package/sources/promiseAsyncResult.ts +173 -173
- package/sources/queue.ts +48 -48
- package/sources/recreationDotGovClient.ts +258 -258
- package/sources/searchControl.ts +41 -41
- package/sources/set.ts +243 -243
- package/sources/skipAsyncIterator.ts +144 -144
- package/sources/stack.ts +47 -47
- package/sources/syncResult.ts +299 -299
- package/sources/takeAsyncIterator.ts +140 -140
- package/sources/whereAsyncIterator.ts +142 -142
- package/sources/wonderlandTrailClient.ts +1502 -1502
- package/tests/assertTestTests.ts +74 -74
- package/tests/byteListStreamTests.ts +389 -389
- package/tests/byteListTests.ts +26 -26
- package/tests/characterListStreamTests.ts +390 -390
- package/tests/characterListTests.ts +249 -249
- package/tests/dateTimeTests.ts +29 -29
- package/tests/depthFirstSearchTests.ts +105 -105
- package/tests/generatorTests.ts +85 -85
- package/tests/mutableMapTests.ts +153 -153
- package/tests/promiseAsyncResultTests.ts +687 -687
- package/tests/queueTests.ts +28 -28
- package/tests/recreationDotGovClientTests.ts +190 -190
- package/tests/setTests.ts +139 -139
- package/tests/stackTests.ts +65 -65
- package/tests/syncResultTests.ts +1250 -1250
- package/tests/wonderlandTrailClientTests.ts +451 -451
- package/tsup.config.ts +12 -12
|
@@ -1,391 +1,391 @@
|
|
|
1
|
-
import { CharacterList } from "../sources/characterList";
|
|
2
|
-
import { CharacterListStream } from "../sources/characterListStream";
|
|
3
|
-
import { EmptyError } from "../sources/emptyError";
|
|
4
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("characterListStream.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("CharacterListStream", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testFunction("create()", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.test("with no arguments", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
19
|
-
test.assertNotUndefinedAndNotNull(stream);
|
|
20
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
runner.test("with empty array", (test: Test) =>
|
|
24
|
-
{
|
|
25
|
-
const stream: CharacterListStream = CharacterListStream.create([]);
|
|
26
|
-
test.assertNotUndefinedAndNotNull(stream);
|
|
27
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
runner.test("with non-empty array", (test: Test) =>
|
|
31
|
-
{
|
|
32
|
-
const stream: CharacterListStream = CharacterListStream.create("abc");
|
|
33
|
-
test.assertNotUndefinedAndNotNull(stream);
|
|
34
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
runner.testFunction("writeCharacters()", () =>
|
|
39
|
-
{
|
|
40
|
-
runner.test("with undefined characters", (test: Test) =>
|
|
41
|
-
{
|
|
42
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
43
|
-
test.assertThrows(() => stream.writeCharacters(undefined!), new PreConditionError(
|
|
44
|
-
"Expression: characters",
|
|
45
|
-
"Expected: not undefined and not null",
|
|
46
|
-
"Actual: undefined",
|
|
47
|
-
));
|
|
48
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
runner.test("with null characters", (test: Test) =>
|
|
52
|
-
{
|
|
53
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
54
|
-
test.assertThrows(() => stream.writeCharacters(null!), new PreConditionError(
|
|
55
|
-
"Expression: characters",
|
|
56
|
-
"Expected: not undefined and not null",
|
|
57
|
-
"Actual: null",
|
|
58
|
-
));
|
|
59
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
runner.test("with empty characters", (test: Test) =>
|
|
63
|
-
{
|
|
64
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
65
|
-
test.assertEqual(0, stream.writeCharacters([]).await());
|
|
66
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
runner.test("with non-empty characters", (test: Test) =>
|
|
70
|
-
{
|
|
71
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
72
|
-
|
|
73
|
-
test.assertEqual(4, stream.writeCharacters("abcd").await());
|
|
74
|
-
test.assertEqual(4, stream.getAvailableCharacterCount());
|
|
75
|
-
|
|
76
|
-
const characters: string = stream.readCharacters(10).await();
|
|
77
|
-
test.assertNotUndefinedAndNotNull(characters);
|
|
78
|
-
test.assertEqual(4, characters.length);
|
|
79
|
-
test.assertEqual("abcd", characters);
|
|
80
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
runner.test("with negative startIndex", (test: Test) =>
|
|
84
|
-
{
|
|
85
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
86
|
-
test.assertThrows(() => stream.writeCharacters("ab", -1), new PreConditionError(
|
|
87
|
-
"Expression: startIndex",
|
|
88
|
-
"Expected: between 0 and 2",
|
|
89
|
-
"Actual: -1",
|
|
90
|
-
));
|
|
91
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
runner.test("with too large startIndex", (test: Test) =>
|
|
95
|
-
{
|
|
96
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
97
|
-
test.assertThrows(() => stream.writeCharacters("ab", 3), new PreConditionError(
|
|
98
|
-
"Expression: startIndex",
|
|
99
|
-
"Expected: between 0 and 2",
|
|
100
|
-
"Actual: 3",
|
|
101
|
-
));
|
|
102
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
runner.test("with valid non-zero startIndex", (test: Test) =>
|
|
106
|
-
{
|
|
107
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
108
|
-
const writeCharactersResult: number = stream.writeCharacters("ab", 1).await();
|
|
109
|
-
test.assertEqual(1, writeCharactersResult);
|
|
110
|
-
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
111
|
-
|
|
112
|
-
test.assertEqual("b", stream.readCharacters(5).await());
|
|
113
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
runner.test("with startIndex equal to characters length", (test: Test) =>
|
|
117
|
-
{
|
|
118
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
119
|
-
const writeCharactersResult: number = stream.writeCharacters("ab", 2).await();
|
|
120
|
-
test.assertEqual(0, writeCharactersResult);
|
|
121
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
runner.test("with negative length", (test: Test) =>
|
|
125
|
-
{
|
|
126
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
127
|
-
test.assertThrows(() => stream.writeCharacters("ab", 0, -1), new PreConditionError(
|
|
128
|
-
"Expression: length",
|
|
129
|
-
"Expected: between 0 and 2",
|
|
130
|
-
"Actual: -1",
|
|
131
|
-
));
|
|
132
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
runner.test("with too large length", (test: Test) =>
|
|
136
|
-
{
|
|
137
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
138
|
-
test.assertThrows(() => stream.writeCharacters("ab", 0, 3), new PreConditionError(
|
|
139
|
-
"Expression: length",
|
|
140
|
-
"Expected: between 0 and 2",
|
|
141
|
-
"Actual: 3",
|
|
142
|
-
));
|
|
143
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
runner.test("with valid startIndex and length values", (test: Test) =>
|
|
147
|
-
{
|
|
148
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
149
|
-
const writeCharactersResult: number = stream.writeCharacters(["a", "b", "c", "d", "e"], 2, 2).await();
|
|
150
|
-
test.assertEqual(2, writeCharactersResult);
|
|
151
|
-
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
152
|
-
|
|
153
|
-
test.assertEqual("cd", stream.readCharacters(50).await());
|
|
154
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
runner.testFunction("readCharacters()", () =>
|
|
159
|
-
{
|
|
160
|
-
runner.testGroup("with empty stream", () =>
|
|
161
|
-
{
|
|
162
|
-
runner.test("with negative count", (test: Test) =>
|
|
163
|
-
{
|
|
164
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
165
|
-
test.assertThrows(() => stream.readCharacters(-1).await(), new PreConditionError(
|
|
166
|
-
"Expression: count",
|
|
167
|
-
"Expected: greater than or equal to 0",
|
|
168
|
-
"Actual: -1",
|
|
169
|
-
));
|
|
170
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
runner.test("with zero count", (test: Test) =>
|
|
174
|
-
{
|
|
175
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
176
|
-
test.assertThrows(() => stream.readCharacters(0).await(), new EmptyError());
|
|
177
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
runner.test("with positive count", (test: Test) =>
|
|
181
|
-
{
|
|
182
|
-
const stream: CharacterListStream = CharacterListStream.create();
|
|
183
|
-
test.assertThrows(() => stream.readCharacters(1).await(), new EmptyError());
|
|
184
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
runner.testGroup("with non-empty stream", () =>
|
|
189
|
-
{
|
|
190
|
-
runner.test("with negative count", (test: Test) =>
|
|
191
|
-
{
|
|
192
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
193
|
-
test.assertThrows(() => stream.readCharacters(-1).await(), new PreConditionError(
|
|
194
|
-
"Expression: count",
|
|
195
|
-
"Expected: greater than or equal to 0",
|
|
196
|
-
"Actual: -1",
|
|
197
|
-
));
|
|
198
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
runner.test("with zero count", (test: Test) =>
|
|
202
|
-
{
|
|
203
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
204
|
-
const readCharactersResult: string = stream.readCharacters(0).await();
|
|
205
|
-
test.assertEqual("", readCharactersResult);
|
|
206
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
runner.test("with positive count less than characters available", (test: Test) =>
|
|
210
|
-
{
|
|
211
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
212
|
-
const readCharactersResult: string = stream.readCharacters(2).await();
|
|
213
|
-
test.assertEqual("ab", readCharactersResult);
|
|
214
|
-
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
runner.test("with positive count equal to characters available", (test: Test) =>
|
|
218
|
-
{
|
|
219
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
220
|
-
const readCharactersResult: string = stream.readCharacters(3).await();
|
|
221
|
-
test.assertEqual("abc", readCharactersResult);
|
|
222
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
runner.test("with positive count greater than characters available", (test: Test) =>
|
|
226
|
-
{
|
|
227
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
228
|
-
const readCharactersResult: string = stream.readCharacters(4).await();
|
|
229
|
-
test.assertEqual("abc", readCharactersResult);
|
|
230
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
runner.test("with undefined output", (test: Test) =>
|
|
234
|
-
{
|
|
235
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
236
|
-
test.assertThrows(() => stream.readCharacters(undefined!), new PreConditionError(
|
|
237
|
-
"Expression: output",
|
|
238
|
-
"Expected: not undefined and not null",
|
|
239
|
-
"Actual: undefined",
|
|
240
|
-
));
|
|
241
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
runner.test("with null output", (test: Test) =>
|
|
245
|
-
{
|
|
246
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
247
|
-
test.assertThrows(() => stream.readCharacters(null!), new PreConditionError(
|
|
248
|
-
"Expression: output",
|
|
249
|
-
"Expected: not undefined and not null",
|
|
250
|
-
"Actual: null",
|
|
251
|
-
));
|
|
252
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
runner.test("with empty output", (test: Test) =>
|
|
256
|
-
{
|
|
257
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
258
|
-
const output: string[] = [];
|
|
259
|
-
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
260
|
-
test.assertEqual(0, readCharactersResult);
|
|
261
|
-
test.assertEqual(output, []);
|
|
262
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
runner.test("with output smaller than the available characters", (test: Test) =>
|
|
266
|
-
{
|
|
267
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
268
|
-
const output: string[] = new Array(1);
|
|
269
|
-
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
270
|
-
test.assertEqual(1, readCharactersResult);
|
|
271
|
-
test.assertEqual(output, ["a"]);
|
|
272
|
-
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
runner.test("with output equal to the available characters", (test: Test) =>
|
|
276
|
-
{
|
|
277
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
278
|
-
const output: string[] = new Array(5).fill("");
|
|
279
|
-
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
280
|
-
test.assertEqual(3, readCharactersResult);
|
|
281
|
-
test.assertEqual(output, ["a", "b", "c", "", ""]);
|
|
282
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
runner.test("with output larger than available characters", (test: Test) =>
|
|
286
|
-
{
|
|
287
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
288
|
-
const output: string[] = new Array(5).fill("");
|
|
289
|
-
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
290
|
-
test.assertEqual(3, readCharactersResult);
|
|
291
|
-
test.assertEqual(output, ["a", "b", "c", "", ""]);
|
|
292
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
runner.test("with negative startIndex", (test: Test) =>
|
|
296
|
-
{
|
|
297
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
298
|
-
const output: string[] = new Array(5);
|
|
299
|
-
test.assertThrows(() => stream.readCharacters(output, -1), new PreConditionError(
|
|
300
|
-
"Expression: startIndex",
|
|
301
|
-
"Expected: between 0 and 5",
|
|
302
|
-
"Actual: -1",
|
|
303
|
-
));
|
|
304
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
runner.test("with too large startIndex", (test: Test) =>
|
|
308
|
-
{
|
|
309
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
310
|
-
const output: string[] = new Array(5);
|
|
311
|
-
test.assertThrows(() => stream.readCharacters(output, 6), new PreConditionError(
|
|
312
|
-
"Expression: startIndex",
|
|
313
|
-
"Expected: between 0 and 5",
|
|
314
|
-
"Actual: 6",
|
|
315
|
-
));
|
|
316
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
runner.test("with startIndex with enough space to read the entire stream", (test: Test) =>
|
|
320
|
-
{
|
|
321
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
322
|
-
const output: string[] = new Array(5).fill("");
|
|
323
|
-
test.assertEqual(3, stream.readCharacters(output, 2).await());
|
|
324
|
-
test.assertEqual(["", "", "a", "b", "c"], output);
|
|
325
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
runner.test("with startIndex with not enough space to read the entire stream", (test: Test) =>
|
|
329
|
-
{
|
|
330
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
331
|
-
const output: string[] = new Array(5).fill("");
|
|
332
|
-
test.assertEqual(2, stream.readCharacters(output, 3).await());
|
|
333
|
-
test.assertEqual(["", "", "", "a", "b"], output);
|
|
334
|
-
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
runner.test("with startIndex equal to output length", (test: Test) =>
|
|
338
|
-
{
|
|
339
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
340
|
-
const output: string[] = new Array(5).fill("");
|
|
341
|
-
test.assertEqual(0, stream.readCharacters(output, 5).await());
|
|
342
|
-
test.assertEqual(["", "", "", "", ""], output);
|
|
343
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
runner.test("with negative count", (test: Test) =>
|
|
347
|
-
{
|
|
348
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
349
|
-
const output: string[] = new Array(5);
|
|
350
|
-
test.assertThrows(() => stream.readCharacters(output, 1, -1), new PreConditionError(
|
|
351
|
-
"Expression: count",
|
|
352
|
-
"Expected: between 0 and 4",
|
|
353
|
-
"Actual: -1",
|
|
354
|
-
));
|
|
355
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
runner.test("with count larger than output.length - startIndex", (test: Test) =>
|
|
359
|
-
{
|
|
360
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
361
|
-
const output: string[] = new Array(5);
|
|
362
|
-
test.assertThrows(() => stream.readCharacters(output, 1, 5), new PreConditionError(
|
|
363
|
-
"Expression: count",
|
|
364
|
-
"Expected: between 0 and 4",
|
|
365
|
-
"Actual: 5",
|
|
366
|
-
));
|
|
367
|
-
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
runner.test("with startIndex with enough space to read the entire stream", (test: Test) =>
|
|
371
|
-
{
|
|
372
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
373
|
-
const output: string[] = new Array(5).fill("");
|
|
374
|
-
test.assertEqual(3, stream.readCharacters(output, 2, 3).await());
|
|
375
|
-
test.assertEqual(["", "", "a", "b", "c"], output);
|
|
376
|
-
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
runner.test("with startIndex with not enough space to read the entire stream", (test: Test) =>
|
|
380
|
-
{
|
|
381
|
-
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
382
|
-
const output: string[] = new Array(5).fill("");
|
|
383
|
-
test.assertEqual(1, stream.readCharacters(output, 3, 1).await());
|
|
384
|
-
test.assertEqual(["", "", "", "a", ""], output);
|
|
385
|
-
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
});
|
|
1
|
+
import { CharacterList } from "../sources/characterList";
|
|
2
|
+
import { CharacterListStream } from "../sources/characterListStream";
|
|
3
|
+
import { EmptyError } from "../sources/emptyError";
|
|
4
|
+
import { PreConditionError } from "../sources/preConditionError";
|
|
5
|
+
import { Test } from "./test";
|
|
6
|
+
import { TestRunner } from "./testRunner";
|
|
7
|
+
|
|
8
|
+
export function test(runner: TestRunner): void
|
|
9
|
+
{
|
|
10
|
+
runner.testFile("characterListStream.ts", () =>
|
|
11
|
+
{
|
|
12
|
+
runner.testType("CharacterListStream", () =>
|
|
13
|
+
{
|
|
14
|
+
runner.testFunction("create()", () =>
|
|
15
|
+
{
|
|
16
|
+
runner.test("with no arguments", (test: Test) =>
|
|
17
|
+
{
|
|
18
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
19
|
+
test.assertNotUndefinedAndNotNull(stream);
|
|
20
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
runner.test("with empty array", (test: Test) =>
|
|
24
|
+
{
|
|
25
|
+
const stream: CharacterListStream = CharacterListStream.create([]);
|
|
26
|
+
test.assertNotUndefinedAndNotNull(stream);
|
|
27
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
runner.test("with non-empty array", (test: Test) =>
|
|
31
|
+
{
|
|
32
|
+
const stream: CharacterListStream = CharacterListStream.create("abc");
|
|
33
|
+
test.assertNotUndefinedAndNotNull(stream);
|
|
34
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
runner.testFunction("writeCharacters()", () =>
|
|
39
|
+
{
|
|
40
|
+
runner.test("with undefined characters", (test: Test) =>
|
|
41
|
+
{
|
|
42
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
43
|
+
test.assertThrows(() => stream.writeCharacters(undefined!), new PreConditionError(
|
|
44
|
+
"Expression: characters",
|
|
45
|
+
"Expected: not undefined and not null",
|
|
46
|
+
"Actual: undefined",
|
|
47
|
+
));
|
|
48
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
runner.test("with null characters", (test: Test) =>
|
|
52
|
+
{
|
|
53
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
54
|
+
test.assertThrows(() => stream.writeCharacters(null!), new PreConditionError(
|
|
55
|
+
"Expression: characters",
|
|
56
|
+
"Expected: not undefined and not null",
|
|
57
|
+
"Actual: null",
|
|
58
|
+
));
|
|
59
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
runner.test("with empty characters", (test: Test) =>
|
|
63
|
+
{
|
|
64
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
65
|
+
test.assertEqual(0, stream.writeCharacters([]).await());
|
|
66
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
runner.test("with non-empty characters", (test: Test) =>
|
|
70
|
+
{
|
|
71
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
72
|
+
|
|
73
|
+
test.assertEqual(4, stream.writeCharacters("abcd").await());
|
|
74
|
+
test.assertEqual(4, stream.getAvailableCharacterCount());
|
|
75
|
+
|
|
76
|
+
const characters: string = stream.readCharacters(10).await();
|
|
77
|
+
test.assertNotUndefinedAndNotNull(characters);
|
|
78
|
+
test.assertEqual(4, characters.length);
|
|
79
|
+
test.assertEqual("abcd", characters);
|
|
80
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
runner.test("with negative startIndex", (test: Test) =>
|
|
84
|
+
{
|
|
85
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
86
|
+
test.assertThrows(() => stream.writeCharacters("ab", -1), new PreConditionError(
|
|
87
|
+
"Expression: startIndex",
|
|
88
|
+
"Expected: between 0 and 2",
|
|
89
|
+
"Actual: -1",
|
|
90
|
+
));
|
|
91
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
runner.test("with too large startIndex", (test: Test) =>
|
|
95
|
+
{
|
|
96
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
97
|
+
test.assertThrows(() => stream.writeCharacters("ab", 3), new PreConditionError(
|
|
98
|
+
"Expression: startIndex",
|
|
99
|
+
"Expected: between 0 and 2",
|
|
100
|
+
"Actual: 3",
|
|
101
|
+
));
|
|
102
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
runner.test("with valid non-zero startIndex", (test: Test) =>
|
|
106
|
+
{
|
|
107
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
108
|
+
const writeCharactersResult: number = stream.writeCharacters("ab", 1).await();
|
|
109
|
+
test.assertEqual(1, writeCharactersResult);
|
|
110
|
+
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
111
|
+
|
|
112
|
+
test.assertEqual("b", stream.readCharacters(5).await());
|
|
113
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
runner.test("with startIndex equal to characters length", (test: Test) =>
|
|
117
|
+
{
|
|
118
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
119
|
+
const writeCharactersResult: number = stream.writeCharacters("ab", 2).await();
|
|
120
|
+
test.assertEqual(0, writeCharactersResult);
|
|
121
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
runner.test("with negative length", (test: Test) =>
|
|
125
|
+
{
|
|
126
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
127
|
+
test.assertThrows(() => stream.writeCharacters("ab", 0, -1), new PreConditionError(
|
|
128
|
+
"Expression: length",
|
|
129
|
+
"Expected: between 0 and 2",
|
|
130
|
+
"Actual: -1",
|
|
131
|
+
));
|
|
132
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
runner.test("with too large length", (test: Test) =>
|
|
136
|
+
{
|
|
137
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
138
|
+
test.assertThrows(() => stream.writeCharacters("ab", 0, 3), new PreConditionError(
|
|
139
|
+
"Expression: length",
|
|
140
|
+
"Expected: between 0 and 2",
|
|
141
|
+
"Actual: 3",
|
|
142
|
+
));
|
|
143
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
runner.test("with valid startIndex and length values", (test: Test) =>
|
|
147
|
+
{
|
|
148
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
149
|
+
const writeCharactersResult: number = stream.writeCharacters(["a", "b", "c", "d", "e"], 2, 2).await();
|
|
150
|
+
test.assertEqual(2, writeCharactersResult);
|
|
151
|
+
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
152
|
+
|
|
153
|
+
test.assertEqual("cd", stream.readCharacters(50).await());
|
|
154
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
runner.testFunction("readCharacters()", () =>
|
|
159
|
+
{
|
|
160
|
+
runner.testGroup("with empty stream", () =>
|
|
161
|
+
{
|
|
162
|
+
runner.test("with negative count", (test: Test) =>
|
|
163
|
+
{
|
|
164
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
165
|
+
test.assertThrows(() => stream.readCharacters(-1).await(), new PreConditionError(
|
|
166
|
+
"Expression: count",
|
|
167
|
+
"Expected: greater than or equal to 0",
|
|
168
|
+
"Actual: -1",
|
|
169
|
+
));
|
|
170
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
runner.test("with zero count", (test: Test) =>
|
|
174
|
+
{
|
|
175
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
176
|
+
test.assertThrows(() => stream.readCharacters(0).await(), new EmptyError());
|
|
177
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
runner.test("with positive count", (test: Test) =>
|
|
181
|
+
{
|
|
182
|
+
const stream: CharacterListStream = CharacterListStream.create();
|
|
183
|
+
test.assertThrows(() => stream.readCharacters(1).await(), new EmptyError());
|
|
184
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
runner.testGroup("with non-empty stream", () =>
|
|
189
|
+
{
|
|
190
|
+
runner.test("with negative count", (test: Test) =>
|
|
191
|
+
{
|
|
192
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
193
|
+
test.assertThrows(() => stream.readCharacters(-1).await(), new PreConditionError(
|
|
194
|
+
"Expression: count",
|
|
195
|
+
"Expected: greater than or equal to 0",
|
|
196
|
+
"Actual: -1",
|
|
197
|
+
));
|
|
198
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
runner.test("with zero count", (test: Test) =>
|
|
202
|
+
{
|
|
203
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
204
|
+
const readCharactersResult: string = stream.readCharacters(0).await();
|
|
205
|
+
test.assertEqual("", readCharactersResult);
|
|
206
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
runner.test("with positive count less than characters available", (test: Test) =>
|
|
210
|
+
{
|
|
211
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
212
|
+
const readCharactersResult: string = stream.readCharacters(2).await();
|
|
213
|
+
test.assertEqual("ab", readCharactersResult);
|
|
214
|
+
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
runner.test("with positive count equal to characters available", (test: Test) =>
|
|
218
|
+
{
|
|
219
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
220
|
+
const readCharactersResult: string = stream.readCharacters(3).await();
|
|
221
|
+
test.assertEqual("abc", readCharactersResult);
|
|
222
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
runner.test("with positive count greater than characters available", (test: Test) =>
|
|
226
|
+
{
|
|
227
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
228
|
+
const readCharactersResult: string = stream.readCharacters(4).await();
|
|
229
|
+
test.assertEqual("abc", readCharactersResult);
|
|
230
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
runner.test("with undefined output", (test: Test) =>
|
|
234
|
+
{
|
|
235
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
236
|
+
test.assertThrows(() => stream.readCharacters(undefined!), new PreConditionError(
|
|
237
|
+
"Expression: output",
|
|
238
|
+
"Expected: not undefined and not null",
|
|
239
|
+
"Actual: undefined",
|
|
240
|
+
));
|
|
241
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
runner.test("with null output", (test: Test) =>
|
|
245
|
+
{
|
|
246
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
247
|
+
test.assertThrows(() => stream.readCharacters(null!), new PreConditionError(
|
|
248
|
+
"Expression: output",
|
|
249
|
+
"Expected: not undefined and not null",
|
|
250
|
+
"Actual: null",
|
|
251
|
+
));
|
|
252
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
runner.test("with empty output", (test: Test) =>
|
|
256
|
+
{
|
|
257
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
258
|
+
const output: string[] = [];
|
|
259
|
+
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
260
|
+
test.assertEqual(0, readCharactersResult);
|
|
261
|
+
test.assertEqual(output, []);
|
|
262
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
runner.test("with output smaller than the available characters", (test: Test) =>
|
|
266
|
+
{
|
|
267
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
268
|
+
const output: string[] = new Array(1);
|
|
269
|
+
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
270
|
+
test.assertEqual(1, readCharactersResult);
|
|
271
|
+
test.assertEqual(output, ["a"]);
|
|
272
|
+
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
runner.test("with output equal to the available characters", (test: Test) =>
|
|
276
|
+
{
|
|
277
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
278
|
+
const output: string[] = new Array(5).fill("");
|
|
279
|
+
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
280
|
+
test.assertEqual(3, readCharactersResult);
|
|
281
|
+
test.assertEqual(output, ["a", "b", "c", "", ""]);
|
|
282
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
runner.test("with output larger than available characters", (test: Test) =>
|
|
286
|
+
{
|
|
287
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
288
|
+
const output: string[] = new Array(5).fill("");
|
|
289
|
+
const readCharactersResult: number = stream.readCharacters(output).await();
|
|
290
|
+
test.assertEqual(3, readCharactersResult);
|
|
291
|
+
test.assertEqual(output, ["a", "b", "c", "", ""]);
|
|
292
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
runner.test("with negative startIndex", (test: Test) =>
|
|
296
|
+
{
|
|
297
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
298
|
+
const output: string[] = new Array(5);
|
|
299
|
+
test.assertThrows(() => stream.readCharacters(output, -1), new PreConditionError(
|
|
300
|
+
"Expression: startIndex",
|
|
301
|
+
"Expected: between 0 and 5",
|
|
302
|
+
"Actual: -1",
|
|
303
|
+
));
|
|
304
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
runner.test("with too large startIndex", (test: Test) =>
|
|
308
|
+
{
|
|
309
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
310
|
+
const output: string[] = new Array(5);
|
|
311
|
+
test.assertThrows(() => stream.readCharacters(output, 6), new PreConditionError(
|
|
312
|
+
"Expression: startIndex",
|
|
313
|
+
"Expected: between 0 and 5",
|
|
314
|
+
"Actual: 6",
|
|
315
|
+
));
|
|
316
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
runner.test("with startIndex with enough space to read the entire stream", (test: Test) =>
|
|
320
|
+
{
|
|
321
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
322
|
+
const output: string[] = new Array(5).fill("");
|
|
323
|
+
test.assertEqual(3, stream.readCharacters(output, 2).await());
|
|
324
|
+
test.assertEqual(["", "", "a", "b", "c"], output);
|
|
325
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
runner.test("with startIndex with not enough space to read the entire stream", (test: Test) =>
|
|
329
|
+
{
|
|
330
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
331
|
+
const output: string[] = new Array(5).fill("");
|
|
332
|
+
test.assertEqual(2, stream.readCharacters(output, 3).await());
|
|
333
|
+
test.assertEqual(["", "", "", "a", "b"], output);
|
|
334
|
+
test.assertEqual(1, stream.getAvailableCharacterCount());
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
runner.test("with startIndex equal to output length", (test: Test) =>
|
|
338
|
+
{
|
|
339
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
340
|
+
const output: string[] = new Array(5).fill("");
|
|
341
|
+
test.assertEqual(0, stream.readCharacters(output, 5).await());
|
|
342
|
+
test.assertEqual(["", "", "", "", ""], output);
|
|
343
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
runner.test("with negative count", (test: Test) =>
|
|
347
|
+
{
|
|
348
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
349
|
+
const output: string[] = new Array(5);
|
|
350
|
+
test.assertThrows(() => stream.readCharacters(output, 1, -1), new PreConditionError(
|
|
351
|
+
"Expression: count",
|
|
352
|
+
"Expected: between 0 and 4",
|
|
353
|
+
"Actual: -1",
|
|
354
|
+
));
|
|
355
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
runner.test("with count larger than output.length - startIndex", (test: Test) =>
|
|
359
|
+
{
|
|
360
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
361
|
+
const output: string[] = new Array(5);
|
|
362
|
+
test.assertThrows(() => stream.readCharacters(output, 1, 5), new PreConditionError(
|
|
363
|
+
"Expression: count",
|
|
364
|
+
"Expected: between 0 and 4",
|
|
365
|
+
"Actual: 5",
|
|
366
|
+
));
|
|
367
|
+
test.assertEqual(3, stream.getAvailableCharacterCount());
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
runner.test("with startIndex with enough space to read the entire stream", (test: Test) =>
|
|
371
|
+
{
|
|
372
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
373
|
+
const output: string[] = new Array(5).fill("");
|
|
374
|
+
test.assertEqual(3, stream.readCharacters(output, 2, 3).await());
|
|
375
|
+
test.assertEqual(["", "", "a", "b", "c"], output);
|
|
376
|
+
test.assertEqual(0, stream.getAvailableCharacterCount());
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
runner.test("with startIndex with not enough space to read the entire stream", (test: Test) =>
|
|
380
|
+
{
|
|
381
|
+
const stream: CharacterListStream = CharacterListStream.create(["a", "b", "c"]);
|
|
382
|
+
const output: string[] = new Array(5).fill("");
|
|
383
|
+
test.assertEqual(1, stream.readCharacters(output, 3, 1).await());
|
|
384
|
+
test.assertEqual(["", "", "", "a", ""], output);
|
|
385
|
+
test.assertEqual(2, stream.getAvailableCharacterCount());
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
391
|
}
|