advent-of-code/set_test.go

30 lines
447 B
Go
Raw Permalink Normal View History

2024-01-12 12:09:44 -07:00
package aoc_test
2024-01-22 16:07:16 -07:00
import (
"sort"
"testing"
"github.com/matryer/is"
aoc "go.sour.is/advent-of-code"
)
2024-01-12 12:09:44 -07:00
func TestSet(t *testing.T) {
is := is.New(t)
2024-10-30 13:32:44 -06:00
s := aoc.NewSet(1, 2, 3)
2024-01-12 12:09:44 -07:00
is.True(!s.Has(0))
is.True(s.Has(1))
is.True(s.Has(2))
is.True(s.Has(3))
is.True(!s.Has(4))
s.Add(4)
is.True(s.Has(4))
items := s.Items()
sort.Ints(items)
is.Equal(items, []int{1, 2, 3, 4})
2024-10-30 13:32:44 -06:00
is.True(aoc.In(4, items...))
is.True(!aoc.In(99, items...))
2024-01-22 16:07:16 -07:00
}