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

Function TestDuplicateOperation

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

Source from the content-addressed store, hash-verified

79}
80
81func TestDuplicateOperation(t *testing.T) {
82 ba := newBitArray(10)
83
84 err := ba.SetBit(5)
85 if err != nil {
86 t.Fatal(err)
87 }
88
89 err = ba.SetBit(5)
90 if err != nil {
91 t.Fatal(err)
92 }
93
94 result, err := ba.GetBit(5)
95 if err != nil {
96 t.Fatal(err)
97 }
98
99 if !result {
100 t.Errorf(`Expected true at position: %d`, 5)
101 }
102
103 err = ba.ClearBit(5)
104 if err != nil {
105 t.Fatal(err)
106 }
107
108 err = ba.ClearBit(5)
109 if err != nil {
110 t.Fatal(err)
111 }
112
113 result, err = ba.GetBit(5)
114 if err != nil {
115 t.Fatal(err)
116 }
117
118 if result {
119 t.Errorf(`Expected false at position: %d`, 5)
120 }
121}
122
123func TestOutOfBounds(t *testing.T) {
124 ba := newBitArray(4)

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…