MCPcopy Index your code
hub / github.com/Workiva/go-datastructures / TestBitOperations

Function TestBitOperations

bitarray/bitarray_test.go:26–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestBitOperations(t *testing.T) {
27 ba := newBitArray(10)
28
29 err := ba.SetBit(5)
30 if err != nil {
31 t.Fatal(err)
32 }
33
34 result, err := ba.GetBit(5)
35 if err != nil {
36 t.Fatal(err)
37 }
38 if !result {
39 t.Errorf(`Expected true at position: %d`, 5)
40 }
41
42 result, err = ba.GetBit(3)
43 if err != nil {
44 t.Fatal(err)
45 }
46
47 if result {
48 t.Errorf(`Expected false at position %d`, 3)
49 }
50
51 err = ba.ClearBit(5)
52 if err != nil {
53 t.Fatal(err)
54 }
55
56 result, err = ba.GetBit(5)
57 if err != nil {
58 t.Fatal(err)
59 }
60
61 if result {
62 t.Errorf(`Expected false at position: %d`, 5)
63 }
64
65 ba = newBitArray(24)
66 err = ba.SetBit(16)
67 if err != nil {
68 t.Fatal(err)
69 }
70
71 result, err = ba.GetBit(16)
72 if err != nil {
73 t.Fatal(err)
74 }
75
76 if !result {
77 t.Errorf(`Expected true at position: %d`, 16)
78 }
79}
80
81func TestDuplicateOperation(t *testing.T) {
82 ba := newBitArray(10)

Callers

nothing calls this directly

Calls 4

newBitArrayFunction · 0.85
SetBitMethod · 0.65
GetBitMethod · 0.65
ClearBitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…