This repository was archived by the owner on Jul 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbitset_test.go
More file actions
92 lines (69 loc) · 1.29 KB
/
Copy pathbitset_test.go
File metadata and controls
92 lines (69 loc) · 1.29 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package ecs
import (
"reflect"
"testing"
)
func TestSetGetClear(t *testing.T) {
b := newBitset(128)
b.Set(42)
if !b.Get(42) {
t.Errorf("Expected bit 42 to be set")
}
b.Clear(42)
if b.Get(42) {
t.Errorf("Expected bit 42 to be cleared")
}
}
func TestAnd(t *testing.T) {
a := newBitset(128)
b := newBitset(128)
a.Set(10)
a.Set(20)
b.Set(20)
b.Set(30)
a.And(b)
if a.Get(10) {
t.Errorf("Expected bit 10 to be cleared")
}
if !a.Get(20) {
t.Errorf("Expected bit 20 to remain set")
}
if a.Get(30) {
t.Errorf("Expected bit 30 to be cleared")
}
}
func TestOr(t *testing.T) {
a := newBitset(128)
b := newBitset(128)
a.Set(5)
b.Set(6)
a.Or(b)
if !a.Get(5) || !a.Get(6) {
t.Errorf("Expected both bits 5 and 6 to be set after OR")
}
}
func TestAndNot(t *testing.T) {
a := newBitset(128)
b := newBitset(128)
a.Set(5)
a.Set(6)
b.Set(6)
a.AndNot(b)
if !a.Get(5) {
t.Errorf("Expected bit 5 to remain set")
}
if a.Get(6) {
t.Errorf("Expected bit 6 to be cleared after AndNot")
}
}
func TestActiveIDs(t *testing.T) {
b := newBitset(128)
expected := []uint32{3, 5, 64, 127}
for _, i := range expected {
b.Set(i)
}
ids := b.ActiveIDs()
if !reflect.DeepEqual(ids, expected) {
t.Errorf("ActiveIDs mismatch.\nExpected: %v\nGot: %v", expected, ids)
}
}