MCPcopy
hub / github.com/RoaringBitmap/roaring / TestBitMapValidationFromFrozen

Function TestBitMapValidationFromFrozen

serialization_frozen_test.go:139–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestBitMapValidationFromFrozen(t *testing.T) {
140 // To understand what is going on here, read https://github.com/RoaringBitmap/RoaringFormatSpec
141 // Maintainers: The loader and corruptor are dependent on one another
142 // The tests expect a certain size, with values at certain location.
143 // The tests are geared toward single byte corruption.
144
145 // There is no way to test Bitmap container corruption once the bitmap is deserialized
146
147 deserializationTests := []struct {
148 name string
149 loader func(bm *Bitmap)
150 corruptor func(s []byte)
151 err error
152 }{
153 {
154 name: "Corrupts Run Length vs Num Runs",
155 loader: func(bm *Bitmap) {
156 bm.AddRange(0, 2)
157 bm.AddRange(4, 6)
158 bm.AddRange(8, 100)
159 },
160 corruptor: func(s []byte) {
161 // 21 is the length of the run of the last run/range
162 // Shortening causes interval sum to be to short
163 s[10] = 1
164 },
165 err: ErrRunIntervalSize,
166 },
167 {
168 name: "Corrupts Run Length",
169 loader: func(bm *Bitmap) {
170 bm.AddRange(100, 110)
171 },
172 corruptor: func(s []byte) {
173 s[2] = 0
174 },
175 err: ErrRunIntervalSize,
176 },
177 {
178 name: "Creates Interval Overlap",
179 loader: func(bm *Bitmap) {
180 bm.AddRange(100, 110)
181 bm.AddRange(115, 125)
182 },
183 corruptor: func(s []byte) {
184 // sets the start of the second run
185 // Creates overlapping intervals
186 s[4] = 108
187 },
188 err: ErrRunIntervalOverlap,
189 },
190 {
191 name: "Break Array Sort Order",
192 loader: func(bm *Bitmap) {
193 arrayEntries := make([]uint32, 0, 10)
194 for i := 0; i < 10; i++ {
195 arrayEntries = append(arrayEntries, uint32(i))
196 }

Callers

nothing calls this directly

Calls 6

AddRangeMethod · 0.95
AddManyMethod · 0.95
ValidateMethod · 0.95
FreezeMethod · 0.95
MustFrozenViewMethod · 0.95
NewBitmapFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…