Files
redis-go/datastruct/set/set_test.go
2021-05-02 14:54:42 +08:00

33 lines
608 B
Go

package set
import (
"strconv"
"testing"
)
func TestSet(t *testing.T) {
size := 10
set := Make()
for i := 0; i < size; i++ {
set.Add(strconv.Itoa(i))
}
for i := 0; i < size; i++ {
ok := set.Has(strconv.Itoa(i))
if !ok {
t.Error("expected true actual false, key: " + strconv.Itoa(i))
}
}
for i := 0; i < size; i++ {
ok := set.Remove(strconv.Itoa(i))
if ok != 1 {
t.Error("expected true actual false, key: " + strconv.Itoa(i))
}
}
for i := 0; i < size; i++ {
ok := set.Has(strconv.Itoa(i))
if ok {
t.Error("expected false actual true, key: " + strconv.Itoa(i))
}
}
}