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

Function TestAndSparseWithSmallerDenseBitArray

bitarray/and_test.go:108–137  ·  view source on GitHub ↗

Make sure that the sparse array is trimmed correctly if compared against a smaller dense bit array.

(t *testing.T)

Source from the content-addressed store, hash-verified

106// Make sure that the sparse array is trimmed correctly if compared against a
107// smaller dense bit array.
108func TestAndSparseWithSmallerDenseBitArray(t *testing.T) {
109 sba := newSparseBitArray()
110 other := newBitArray(512)
111
112 other.SetBit(1)
113 sba.SetBit(1)
114 other.SetBit(150)
115 sba.SetBit(150)
116 sba.SetBit(155)
117 sba.SetBit(500)
118
119 other.SetBit(128)
120 sba.SetBit(1500)
121 sba.SetBit(1200)
122
123 ba := andSparseWithDenseBitArray(sba, other)
124
125 // Bits in both
126 checkBit(t, ba, 1, true)
127 checkBit(t, ba, 150, true)
128
129 // Bits in sba but not other
130 checkBit(t, ba, 155, false)
131 checkBit(t, ba, 500, false)
132 checkBit(t, ba, 1200, false)
133 checkBit(t, ba, 1500, false)
134
135 // Bits in other but not sba
136 checkBit(t, ba, 128, false)
137}
138
139func TestAndDenseWithDenseBitArray(t *testing.T) {
140 dba := newBitArray(1000)

Callers

nothing calls this directly

Calls 5

newSparseBitArrayFunction · 0.85
newBitArrayFunction · 0.85
checkBitFunction · 0.85
SetBitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…