fix: request cleanup jobs
This commit is contained in:
@@ -62,11 +62,13 @@ type BoundSet[T ordered] struct {
|
||||
}
|
||||
|
||||
func NewBoundSet[T ordered](min, max T, items ...T) *BoundSet[T] {
|
||||
return &BoundSet[T]{
|
||||
b := &BoundSet[T]{
|
||||
min: min,
|
||||
max: max,
|
||||
s: New(items...),
|
||||
s: New[T](),
|
||||
}
|
||||
b.Add(items...)
|
||||
return b
|
||||
}
|
||||
func (l *BoundSet[T]) Add(items ...T) *BoundSet[T] {
|
||||
n := 0
|
||||
@@ -110,5 +112,10 @@ func (l *BoundSet[T]) String() string {
|
||||
n++
|
||||
}
|
||||
sort.Strings(lis)
|
||||
return strings.Join(lis, ",")
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("set(")
|
||||
b.WriteString(strings.Join(lis, ","))
|
||||
b.WriteString(")")
|
||||
return b.String()
|
||||
}
|
||||
|
||||
@@ -23,3 +23,17 @@ func TestStringSet(t *testing.T) {
|
||||
var n set.Set[string]
|
||||
is.Equal(n.String(), "set(<nil>)")
|
||||
}
|
||||
|
||||
func TestBoundSet(t *testing.T) {
|
||||
is := is.New(t)
|
||||
|
||||
s := set.NewBoundSet(1, 100, 1, 2, 3, 100, 1001)
|
||||
|
||||
is.True(s.Has(1))
|
||||
is.True(s.Has(2))
|
||||
is.True(s.Has(3))
|
||||
is.True(!s.Has(1001))
|
||||
|
||||
is.Equal(set.NewBoundSet(1, 100, 1).String(), "set(1)")
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user