(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func 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 | |
| 55 | func TestOr(t *testing.T) { |
| 56 |
nothing calls this directly
no test coverage detected