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

Function TestOr

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

Source from the content-addressed store, hash-verified

53}
54
55func TestOr(t *testing.T) {
56
57 bA1, _ := randBitArray(51)
58 bA2, _ := randBitArray(31)
59 bA3 := bA1.Or(bA2)
60
61 bNil := (*BitArray)(nil)
62 require.Equal(t, bNil.Or(bA1), bA1)
63 require.Equal(t, bA1.Or(nil), bA1)
64 require.Equal(t, bNil.Or(nil), (*BitArray)(nil))
65
66 if bA3.Bits != 51 {
67 t.Error("Expected max bits")
68 }
69 if len(bA3.Elems) != len(bA1.Elems) {
70 t.Error("Expected max elems length")
71 }
72 for i := 0; i < bA3.Bits; i++ {
73 expected := bA1.GetIndex(i) || bA2.GetIndex(i)
74 if bA3.GetIndex(i) != expected {
75 t.Error("Wrong bit from bA3", i, bA1.GetIndex(i), bA2.GetIndex(i), bA3.GetIndex(i))
76 }
77 }
78}
79
80func TestSub(t *testing.T) {
81 testCases := []struct {

Callers

nothing calls this directly

Calls 5

randBitArrayFunction · 0.85
OrMethod · 0.80
EqualMethod · 0.65
ErrorMethod · 0.65
GetIndexMethod · 0.45

Tested by

no test coverage detected