42 lines
563 B
Go
42 lines
563 B
Go
package pkg
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSet(t *testing.T) {
|
|
set := NewSet(4)
|
|
keys := []string{
|
|
"1", "2", "3", "something",
|
|
}
|
|
|
|
t.Run("SetAddItem", func(t *testing.T) {
|
|
for _, key := range keys {
|
|
set.Set(key)
|
|
}
|
|
|
|
if len(set) != len(keys) {
|
|
t.Fatal()
|
|
}
|
|
})
|
|
|
|
t.Run("SetHasItem", func(t *testing.T) {
|
|
var has bool
|
|
for _, key := range keys {
|
|
has = set.Has(key)
|
|
if !has {
|
|
t.Fatal()
|
|
}
|
|
}
|
|
})
|
|
|
|
t.Run("SetDelItem", func(t *testing.T) {
|
|
for _, key := range keys {
|
|
set.Del(key)
|
|
}
|
|
if len(set) != 0 {
|
|
t.Fatal()
|
|
}
|
|
})
|
|
}
|