func TestMinAndMax(t *testing.T) { values := []int{0, 456, 123, 789, -123} // elt 0 => empty set wantMax := []int{intsets.MinInt, 456, 456, 789, 789} wantMin := []int{intsets.MaxInt, 456, 123, 123, -123} var set intsets.Sparse for i, x := range values { if i != 0 { set.Insert(x) } if got, want := set.Min(), wantMin[i]; got != want { t.Errorf("Min #%d: got %d, want %d", i, got, want) } if got, want := set.Max(), wantMax[i]; got != want { t.Errorf("Max #%d: got %d, want %d", i, got, want) } } set.Insert(intsets.MinInt) if got, want := set.Min(), intsets.MinInt; got != want { t.Errorf("Min: got %d, want %d", got, want) } set.Insert(intsets.MaxInt) if got, want := set.Max(), intsets.MaxInt; got != want { t.Errorf("Max: got %d, want %d", got, want) } }