func TestSubsetOf(t *testing.T) { prng := rand.New(rand.NewSource(0)) for i := uint(0); i < 12; i++ { X, Y := randomPset(prng, 1<<i), randomPset(prng, 1<<i) x, y := &X.bits, &Y.bits // test the slow way var z intsets.Sparse z.Copy(x) z.DifferenceWith(y) if got, want := x.SubsetOf(y), z.IsEmpty(); got != want { t.Errorf("SubsetOf: got %v, want %v", got, want) } // make it true y.UnionWith(x) if got, want := x.SubsetOf(y), true; got != want { t.Errorf("SubsetOf: got %v, want %v", got, want) } // make it false if x.IsEmpty() { continue } a := x.AppendTo(nil) i := prng.Intn(len(a)) y.Remove(a[i]) if got, want := x.SubsetOf(y), false; got != want { t.Errorf("SubsetOf: got %v, want %v", got, want) } } }