Skip to content

Instantly share code, notes, and snippets.

@sausheong
Created May 16, 2022 06:49
Show Gist options
  • Save sausheong/911f07db9a1a4e00dad9536befa8715d to your computer and use it in GitHub Desktop.
Save sausheong/911f07db9a1a4e00dad9536befa8715d to your computer and use it in GitHub Desktop.
generics
func TestTSetInt(t *testing.T) {
set := NewTSet[int]()
set.Add(100)
set.Add(200)
set.Add(300)
set.Add(400)
if !set.Has(400) {
t.Error("set doesn't have 400")
}
list := set.List()
sort.Slice(list, func(i, j int) bool {
return list[i] < list[j]
})
if !reflect.DeepEqual(list, []int{100, 200, 300, 400}) {
t.Error(list)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment