MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestBitArrayFromProto

Function TestBitArrayFromProto

libs/bits/bit_array_test.go:295–322  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

293}
294
295func TestBitArrayFromProto(t *testing.T) {
296 testCases := []struct {
297 pbA *tmprotobits.BitArray
298 resA *BitArray
299 expErr bool
300 }{
301 0: {nil, &BitArray{}, false},
302 1: {&tmprotobits.BitArray{}, &BitArray{Elems: []uint64{}}, false},
303
304 2: {&tmprotobits.BitArray{Bits: 1, Elems: make([]uint64, 1)}, &BitArray{Bits: 1, Elems: make([]uint64, 1)}, false},
305
306 3: {&tmprotobits.BitArray{Bits: -1, Elems: make([]uint64, 1)}, &BitArray{}, true},
307 4: {&tmprotobits.BitArray{Bits: math.MaxInt32 + 1, Elems: make([]uint64, 1)}, &BitArray{}, true},
308 5: {&tmprotobits.BitArray{Bits: 1, Elems: make([]uint64, 2)}, &BitArray{}, true},
309 }
310
311 for i, tc := range testCases {
312 bA := new(BitArray)
313 err := bA.FromProto(tc.pbA)
314 if tc.expErr {
315 assert.Error(t, err, "#%d", i)
316 assert.Equal(t, tc.resA, bA, "#%d", i)
317 } else {
318 assert.NoError(t, err, "#%d", i)
319 assert.Equal(t, tc.resA, bA, "#%d", i)
320 }
321 }
322}

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.65
EqualMethod · 0.65
FromProtoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…