private void Validate_IntersectWith(PooledSet <T> set, Span <T> span) { if (set.Count == 0 || span.Length == 0) { set.IntersectWith(span); Assert.Equal(0, set.Count); } else { IEqualityComparer <T> comparer = set.Comparer; PooledSet <T> expected = new PooledSet <T>(comparer); RegisterForDispose(expected); foreach (T value in set) { if (SpanContains(span, value, comparer)) { expected.Add(value); } } set.IntersectWith(span); Assert.Equal(expected.Count, set.Count); Assert.True(expected.SetEquals(set)); } }