MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestAnd

Function TestAnd

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

Source from the content-addressed store, hash-verified

28}
29
30func TestAnd(t *testing.T) {
31
32 bA1, _ := randBitArray(51)
33 bA2, _ := randBitArray(31)
34 bA3 := bA1.And(bA2)
35
36 var bNil *BitArray
37 require.Equal(t, bNil.And(bA1), (*BitArray)(nil))
38 require.Equal(t, bA1.And(nil), (*BitArray)(nil))
39 require.Equal(t, bNil.And(nil), (*BitArray)(nil))
40
41 if bA3.Bits != 31 {
42 t.Error("Expected min bits", bA3.Bits)
43 }
44 if len(bA3.Elems) != len(bA2.Elems) {
45 t.Error("Expected min elems length")
46 }
47 for i := 0; i < bA3.Bits; i++ {
48 expected := bA1.GetIndex(i) && bA2.GetIndex(i)
49 if bA3.GetIndex(i) != expected {
50 t.Error("Wrong bit from bA3", i, bA1.GetIndex(i), bA2.GetIndex(i), bA3.GetIndex(i))
51 }
52 }
53}
54
55func TestOr(t *testing.T) {
56

Callers

nothing calls this directly

Calls 5

AndMethod · 0.95
randBitArrayFunction · 0.85
EqualMethod · 0.65
ErrorMethod · 0.65
GetIndexMethod · 0.45

Tested by

no test coverage detected