deno.land / std@0.173.0 / bytes / repeat_test.ts

repeat_test.ts
نووسراو ببینە
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
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.import { assertEquals, assertThrows } from "../testing/asserts.ts";import { repeat } from "./repeat.ts";
Deno.test("[bytes] repeat", () => { // input / output / count / error message const repeatTestCase = [ ["", "", 0], ["", "", 1], ["", "", 1.1, "bytes: repeat count must be an integer"], ["", "", 2], ["", "", 0], ["-", "", 0], ["-", "-", -1, "bytes: negative repeat count"], ["-", "----------", 10], ["abc ", "abc abc abc ", 3], ]; for (const [input, output, count, errMsg] of repeatTestCase) { if (errMsg) { assertThrows( () => { repeat(new TextEncoder().encode(input as string), count as number); }, Error, errMsg as string, ); } else { const newBytes = repeat( new TextEncoder().encode(input as string), count as number, );
assertEquals(new TextDecoder().decode(newBytes), output); } }});
std

Version Info

Tagged at
a year ago