-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
67 lines (54 loc) · 1008 Bytes
/
tests.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var sdr = require('./');
var test = require('tape');
test('it', function(t){
t.equals(sdr.sparsity([0, 10, 20], 100), 0.03);
t.equals(sdr.capacity(16, 1), 16);
t.equals(sdr.capacity(16, 2), 120);
t.equals(sdr.capacity(2048, 40), 2.3717785116453587e+84);
t.deepEquals(sdr.intersect(
[1, 2],
[2, 3]),
[2]
);
t.deepEquals(sdr.intersect(
[],
[2, 3]),
[]
);
t.deepEquals(sdr.intersect(
[2, 3],
[]),
[]
);
t.deepEquals(sdr.intersect(
[0, 10, 15, 30],
[0, 5, 10, 20]),
[0, 10]
);
t.deepEquals(sdr.union(
[0, 10, 15, 30],
[0, 5, 10, 20]),
[0, 5, 10, 15, 20, 30]
);
t.deepEquals(sdr.union(
[0, 1, 2, 3],
[4, 5, 6, 7]),
[0, 1, 2, 3, 4, 5, 6, 7]
);
t.deepEquals(sdr.union(
[4, 5, 6, 7],
[0, 1, 2, 3]),
[0, 1, 2, 3, 4, 5, 6, 7]
);
t.deepEquals(sdr.union(
[],
[0, 1, 2]),
[0, 1, 2]
);
t.deepEquals(sdr.union(
[0, 1, 2],
[]),
[0, 1, 2]
);
t.end();
});