-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathset_digest_test.go
48 lines (45 loc) · 892 Bytes
/
set_digest_test.go
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
package harfbuzz
import "testing"
func TestDigest(t *testing.T) {
const (
setTypeSize = 2
numBits = 3 + 1 + 1
)
if shift0 >= setTypeSize*8 {
t.Error()
}
if shift0+numBits > setTypeSize*8 {
t.Error()
}
if shift1 >= setTypeSize*8 {
t.Error()
}
if shift1+numBits > setTypeSize*8 {
t.Error()
}
if shift2 >= setTypeSize*8 {
t.Error()
}
if shift2+numBits > setTypeSize*8 {
t.Error()
}
}
func TestDigestHas(t *testing.T) {
var d setDigest
for i := setType(10); i < 65_000; i += 7 {
d.add(i)
}
for i := setType(10); i < 65_000; i += 7 {
if !d.mayHave(i) {
t.Errorf("expected <may have> for %d", i)
}
}
for i := setType(0); i < 0xFFFF; i++ { // care with overflow
// if the filter is negative, then the glyph must not be in the set
if !d.mayHave(i) {
if (i-10)%7 == 0 {
t.Errorf("<not have> for glyph %d present in set", i)
}
}
}
}