-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.mjs
44 lines (34 loc) · 1.17 KB
/
test.mjs
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
import test from 'brittle'
import { cnt } from './fallback.js'
test('cnt', (t) => {
t.test('uint8array', (t) => {
const result = new Uint8Array(16)
cnt(Uint8Array.of(
0b00000000, 0b00000001, 0b00000011, 0b00000111,
0b00001111, 0b00011111, 0b00111111, 0b01111111,
0b11111111, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000
), result)
t.alike(result, Uint8Array.of(0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0))
})
t.test('uint16array', (t) => {
const result = new Uint16Array(8)
cnt(Uint16Array.of(
0b0000000000000000, 0b0000000000000001,
0b0000000000000011, 0b0000000000000111,
0b0000000000001111, 0b0000000000011111,
0b0000000000111111, 0b0000000001111111
), result)
t.alike(result, Uint16Array.of(0, 1, 2, 3, 4, 5, 6, 7))
})
t.test('uint32array', (t) => {
const result = new Uint32Array(4)
cnt(Uint32Array.of(
0b00000000000000000000000000000000,
0b00000000000000000000000000000001,
0b00000000000000000000000000000011,
0b00000000000000000000000000000111
), result)
t.alike(result, Uint32Array.of(0, 1, 2, 3))
})
})