(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func 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 | |
| 80 | func TestSub(t *testing.T) { |
| 81 | testCases := []struct { |
nothing calls this directly
no test coverage detected