mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
33 lines
608 B
Go
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))
|
|
}
|
|
}
|
|
}
|