Created
May 16, 2022 06:49
-
-
Save sausheong/911f07db9a1a4e00dad9536befa8715d to your computer and use it in GitHub Desktop.
generics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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