MCPcopy Create free account
hub / github.com/Workiva/go-datastructures / TestAndSparseWithSparseBitArray

Function TestAndSparseWithSparseBitArray

bitarray/and_test.go:37–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestAndSparseWithSparseBitArray(t *testing.T) {
38 sba := newSparseBitArray()
39 other := newSparseBitArray()
40
41 // bits for which only one of the arrays is set
42 sba.SetBit(3)
43 sba.SetBit(280)
44 other.SetBit(9)
45 other.SetBit(100)
46 sba.SetBit(1000)
47 other.SetBit(1001)
48
49 // bits for which both arrays are set
50 sba.SetBit(1)
51 other.SetBit(1)
52 sba.SetBit(2680)
53 other.SetBit(2680)
54 sba.SetBit(30)
55 other.SetBit(30)
56
57 ba := andSparseWithSparseBitArray(sba, other)
58
59 // Bits in both
60 checkBit(t, ba, 1, true)
61 checkBit(t, ba, 30, true)
62 checkBit(t, ba, 2680, true)
63
64 // Bits in sba but not other
65 checkBit(t, ba, 3, false)
66 checkBit(t, ba, 280, false)
67 checkBit(t, ba, 1000, false)
68
69 // Bits in other but not sba
70 checkBit(t, ba, 9, false)
71 checkBit(t, ba, 100, false)
72 checkBit(t, ba, 2, false)
73
74 nums := ba.ToNums()
75 assert.Equal(t, []uint64{1, 30, 2680}, nums)
76}
77
78func TestAndSparseWithDenseBitArray(t *testing.T) {
79 sba := newSparseBitArray()

Callers

nothing calls this directly

Calls 5

newSparseBitArrayFunction · 0.85
checkBitFunction · 0.85
SetBitMethod · 0.65
ToNumsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…