@everyonesoftware/common 2.0.0 → 4.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.
Files changed (176) hide show
  1. package/outputs/chunk-AY3YWKOM.js +7741 -0
  2. package/outputs/chunk-AY3YWKOM.js.map +1 -0
  3. package/outputs/sources.cjs +9007 -0
  4. package/outputs/sources.cjs.map +1 -0
  5. package/outputs/sources.d.cts +4082 -0
  6. package/outputs/sources.d.ts +4082 -0
  7. package/outputs/sources.js +1370 -0
  8. package/outputs/sources.js.map +1 -0
  9. package/outputs/tests.cjs +17208 -0
  10. package/outputs/tests.cjs.map +1 -0
  11. package/outputs/tests.d.cts +3 -0
  12. package/outputs/tests.d.ts +3 -0
  13. package/outputs/tests.js +9798 -0
  14. package/outputs/tests.js.map +1 -0
  15. package/package.json +11 -2
  16. package/.c8rc.json +0 -12
  17. package/.github/workflows/publish.yml +0 -36
  18. package/.mocharc.json +0 -9
  19. package/sources/assertMessageParameters.ts +0 -22
  20. package/sources/asyncIterator.ts +0 -437
  21. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
  22. package/sources/asyncResult.ts +0 -95
  23. package/sources/basicDisposable.ts +0 -57
  24. package/sources/byteList.ts +0 -202
  25. package/sources/byteListStream.ts +0 -121
  26. package/sources/byteReadStream.ts +0 -24
  27. package/sources/byteWriteStream.ts +0 -16
  28. package/sources/bytes.ts +0 -25
  29. package/sources/characterList.ts +0 -195
  30. package/sources/characterListStream.ts +0 -151
  31. package/sources/characterReadStream.ts +0 -81
  32. package/sources/characterReadStreamIterator.ts +0 -128
  33. package/sources/characterWriteStream.ts +0 -45
  34. package/sources/commandLineParameter.ts +0 -45
  35. package/sources/commandLineParameters.ts +0 -21
  36. package/sources/comparable.ts +0 -144
  37. package/sources/comparer.ts +0 -133
  38. package/sources/comparison.ts +0 -20
  39. package/sources/concatenateIterable.ts +0 -119
  40. package/sources/concatenateIterator.ts +0 -165
  41. package/sources/condition.ts +0 -329
  42. package/sources/currentProcess.ts +0 -158
  43. package/sources/dateTime.ts +0 -130
  44. package/sources/depthFirstSearch.ts +0 -230
  45. package/sources/disposable.ts +0 -31
  46. package/sources/emptyError.ts +0 -10
  47. package/sources/english.ts +0 -45
  48. package/sources/equalFunctions.ts +0 -123
  49. package/sources/fetchHttpClient.ts +0 -89
  50. package/sources/fetchHttpResponse.ts +0 -106
  51. package/sources/flatMapIterable.ts +0 -104
  52. package/sources/flatMapIterator.ts +0 -152
  53. package/sources/generator.ts +0 -251
  54. package/sources/httpClient.ts +0 -36
  55. package/sources/httpHeader.ts +0 -37
  56. package/sources/httpHeaders.ts +0 -216
  57. package/sources/httpIncomingRequest.ts +0 -30
  58. package/sources/httpIncomingResponse.ts +0 -19
  59. package/sources/httpMethod.ts +0 -164
  60. package/sources/httpOutgoingRequest.ts +0 -119
  61. package/sources/httpOutgoingResponse.ts +0 -113
  62. package/sources/httpServer.ts +0 -34
  63. package/sources/inMemoryCharacterWriteStream.ts +0 -78
  64. package/sources/index.ts +0 -101
  65. package/sources/iterable.ts +0 -345
  66. package/sources/iterator.ts +0 -481
  67. package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
  68. package/sources/javascript.ts +0 -59
  69. package/sources/javascriptArrayList.ts +0 -175
  70. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
  71. package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
  72. package/sources/javascriptMapMap.ts +0 -143
  73. package/sources/javascriptSetSet.ts +0 -134
  74. package/sources/list.ts +0 -330
  75. package/sources/listQueue.ts +0 -62
  76. package/sources/listStack.ts +0 -62
  77. package/sources/luxonDateTime.ts +0 -109
  78. package/sources/map.ts +0 -302
  79. package/sources/mapAsyncIterator.ts +0 -141
  80. package/sources/mapIterable.ts +0 -105
  81. package/sources/mapIterator.ts +0 -145
  82. package/sources/mutableCondition.ts +0 -451
  83. package/sources/mutableHttpHeaders.ts +0 -204
  84. package/sources/mutableMap.ts +0 -292
  85. package/sources/network.ts +0 -18
  86. package/sources/node.ts +0 -37
  87. package/sources/nodeJSCharacterWriteStream.ts +0 -42
  88. package/sources/nodeJSHttpIncomingRequest.ts +0 -132
  89. package/sources/nodeJSHttpServer.ts +0 -134
  90. package/sources/notFoundError.ts +0 -12
  91. package/sources/postCondition.ts +0 -284
  92. package/sources/postConditionError.ts +0 -12
  93. package/sources/preCondition.ts +0 -284
  94. package/sources/preConditionError.ts +0 -12
  95. package/sources/promiseAsyncResult.ts +0 -174
  96. package/sources/property.ts +0 -63
  97. package/sources/queue.ts +0 -49
  98. package/sources/realNetwork.ts +0 -28
  99. package/sources/recreationDotGovClient.ts +0 -259
  100. package/sources/searchControl.ts +0 -42
  101. package/sources/set.ts +0 -244
  102. package/sources/skipAsyncIterator.ts +0 -145
  103. package/sources/skipIterator.ts +0 -155
  104. package/sources/stack.ts +0 -48
  105. package/sources/stringComparer.ts +0 -33
  106. package/sources/stringIterator.ts +0 -149
  107. package/sources/strings.ts +0 -322
  108. package/sources/syncResult.ts +0 -300
  109. package/sources/takeAsyncIterator.ts +0 -141
  110. package/sources/takeIterator.ts +0 -151
  111. package/sources/toStringFunctions.ts +0 -185
  112. package/sources/types.ts +0 -371
  113. package/sources/whereAsyncIterator.ts +0 -143
  114. package/sources/whereIterable.ts +0 -108
  115. package/sources/whereIterator.ts +0 -157
  116. package/sources/wonderlandTrailClient.ts +0 -1503
  117. package/tests/assertTest.ts +0 -113
  118. package/tests/assertTestTests.ts +0 -75
  119. package/tests/basicTestSkip.ts +0 -51
  120. package/tests/byteListStreamTests.ts +0 -390
  121. package/tests/byteListTests.ts +0 -27
  122. package/tests/bytesTests.ts +0 -43
  123. package/tests/characterListStreamTests.ts +0 -391
  124. package/tests/characterListTests.ts +0 -250
  125. package/tests/characterWriteStreamTests.ts +0 -12
  126. package/tests/comparerTests.ts +0 -92
  127. package/tests/conditionTests.ts +0 -877
  128. package/tests/consoleTestRunner.ts +0 -404
  129. package/tests/consoleTestRunnerTests.ts +0 -651
  130. package/tests/dateTimeTests.ts +0 -30
  131. package/tests/depthFirstSearchTests.ts +0 -106
  132. package/tests/disposableTests.ts +0 -121
  133. package/tests/englishTests.ts +0 -103
  134. package/tests/equalFunctionsTests.ts +0 -223
  135. package/tests/failedTest.ts +0 -43
  136. package/tests/fetchHttpClientTests.ts +0 -33
  137. package/tests/generatorTests.ts +0 -86
  138. package/tests/httpClientTests.ts +0 -18
  139. package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
  140. package/tests/iterableTests.ts +0 -141
  141. package/tests/iteratorTests.ts +0 -1086
  142. package/tests/javascriptMapMapTests.ts +0 -21
  143. package/tests/listTests.ts +0 -338
  144. package/tests/mapIteratorTests.ts +0 -55
  145. package/tests/mapTests.ts +0 -104
  146. package/tests/mutableConditionTests.ts +0 -273
  147. package/tests/mutableMapTests.ts +0 -154
  148. package/tests/nodeJSHttpServerTests.ts +0 -75
  149. package/tests/notFoundErrorTests.ts +0 -24
  150. package/tests/postConditionErrorTests.ts +0 -24
  151. package/tests/preConditionErrorTests.ts +0 -24
  152. package/tests/promiseAsyncResultTests.ts +0 -688
  153. package/tests/propertyTests.ts +0 -63
  154. package/tests/queueTests.ts +0 -29
  155. package/tests/recreationDotGovClientTests.ts +0 -191
  156. package/tests/setTests.ts +0 -140
  157. package/tests/skippedTest.ts +0 -39
  158. package/tests/stackTests.ts +0 -66
  159. package/tests/stringComparerTests.ts +0 -60
  160. package/tests/stringIteratorTests.ts +0 -156
  161. package/tests/stringsTests.ts +0 -516
  162. package/tests/syncResultTests.ts +0 -1251
  163. package/tests/test.ts +0 -228
  164. package/tests/testAction.ts +0 -75
  165. package/tests/testActionTests.ts +0 -93
  166. package/tests/testFailureTests.ts +0 -12
  167. package/tests/testRunner.ts +0 -267
  168. package/tests/testRunnerTests.ts +0 -895
  169. package/tests/testSkip.ts +0 -34
  170. package/tests/tests.ts +0 -103
  171. package/tests/toStringFunctionsTests.ts +0 -55
  172. package/tests/typesTests.ts +0 -257
  173. package/tests/whereIteratorTests.ts +0 -77
  174. package/tests/wonderlandTrailClientTests.ts +0 -452
  175. package/tsconfig.json +0 -20
  176. package/tsup.config.ts +0 -13
@@ -1,43 +0,0 @@
1
- import { Bytes } from "../sources/bytes";
2
- import { Test } from "./test";
3
- import { TestRunner } from "./testRunner";
4
-
5
- export function test(runner: TestRunner): void
6
- {
7
- runner.testFile("bytes.ts", () =>
8
- {
9
- runner.testType("Bytes", () =>
10
- {
11
- runner.test("minimumValue", (test: Test) =>
12
- {
13
- test.assertSame(Bytes.minimumValue, 0);
14
- });
15
-
16
- runner.test("maximumValue", (test: Test) =>
17
- {
18
- test.assertSame(Bytes.maximumValue, 255);
19
- });
20
-
21
- runner.testFunction("isByte(number)", () =>
22
- {
23
- function isByteTest(value: number, expected: boolean): void
24
- {
25
- runner.test(`with ${value}`, (test: Test) =>
26
- {
27
- test.assertSame(Bytes.isByte(value), expected);
28
- });
29
- }
30
-
31
- isByteTest(-2, false);
32
- isByteTest(-1, false);
33
- isByteTest(0, true);
34
- isByteTest(1, true);
35
- isByteTest(128, true);
36
- isByteTest(254, true);
37
- isByteTest(255, true);
38
- isByteTest(256, false);
39
- isByteTest(257, false);
40
- });
41
- });
42
- });
43
- }
@@ -1,391 +0,0 @@
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
- }