-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat.test.ts
35 lines (32 loc) · 1.03 KB
/
concat.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
import { expect, test } from 'vitest'
import { concat, concatBytes, concatHex } from './concat.js'
test('concat', () => {
expect(concat(['0x0', '0x1'])).toBe('0x01')
expect(concat(['0x1', '0x69', '0x420'])).toBe('0x169420')
expect(concat(['0x00000001', '0x00000069', '0x00000420'])).toBe(
'0x000000010000006900000420',
)
expect(concatHex(['0x00000001', '0x00000069', '0x00000420'])).toBe(
'0x000000010000006900000420',
)
expect(concat([new Uint8Array([0]), new Uint8Array([1])])).toStrictEqual(
new Uint8Array([0, 1]),
)
expect(concatBytes([new Uint8Array([0]), new Uint8Array([1])])).toStrictEqual(
new Uint8Array([0, 1]),
)
expect(
concat([
new Uint8Array([1]),
new Uint8Array([69]),
new Uint8Array([420, 69]),
]),
).toStrictEqual(new Uint8Array([1, 69, 420, 69]))
expect(
concat([
new Uint8Array([0, 0, 0, 1]),
new Uint8Array([0, 0, 0, 69]),
new Uint8Array([0, 0, 420, 69]),
]),
).toStrictEqual(new Uint8Array([0, 0, 0, 1, 0, 0, 0, 69, 0, 0, 420, 69]))
})