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

Function TestNandSparseWithSparseBitArray

bitarray/nand_test.go:25–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestNandSparseWithSparseBitArray(t *testing.T) {
26 sba := newSparseBitArray()
27 other := newSparseBitArray()
28
29 // bits for which only one of the arrays is set
30 sba.SetBit(3)
31 sba.SetBit(280)
32 other.SetBit(9)
33 other.SetBit(100)
34 sba.SetBit(1000)
35 other.SetBit(1001)
36
37 // bits for which both arrays are set
38 sba.SetBit(1)
39 other.SetBit(1)
40 sba.SetBit(2680)
41 other.SetBit(2680)
42 sba.SetBit(30)
43 other.SetBit(30)
44
45 ba := nandSparseWithSparseBitArray(sba, other)
46
47 // Bits in both
48 checkBit(t, ba, 1, false)
49 checkBit(t, ba, 30, false)
50 checkBit(t, ba, 2680, false)
51
52 // Bits in sba but not other
53 checkBit(t, ba, 3, true)
54 checkBit(t, ba, 280, true)
55 checkBit(t, ba, 1000, true)
56
57 // Bits in other but not sba
58 checkBit(t, ba, 9, false)
59 checkBit(t, ba, 100, false)
60 checkBit(t, ba, 2, false)
61
62 nums := ba.ToNums()
63 assert.Equal(t, []uint64{3, 280, 1000}, nums)
64}
65
66func TestNandSparseWithDenseBitArray(t *testing.T) {
67 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…