-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
59 lines (49 loc) · 1.03 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestNewSet(t *testing.T) {
s := NewSet[string]()
assert.Equal(t, 0, s.Size())
}
func TestSetHas(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
assert.True(t, s.Has("foo"))
assert.False(t, s.Has("bar"))
}
func TestSetAdd(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
assert.True(t, s.Has("foo"))
}
func TestSetRemove(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
s.Remove("foo")
assert.False(t, s.Has("foo"))
}
func TestSetClear(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
s.Clear()
assert.False(t, s.Has("foo"))
}
func TestSetSize(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
assert.Equal(t, 1, s.Size())
}
func TestSetEmptyWithoutInit(t *testing.T) {
var s Set[string]
assert.Equal(t, 0, s.Size())
}
func TestSetSlice(t *testing.T) {
s := NewSet[string]()
s.Add("foo")
s.Add("bar")
assert.ElementsMatch(t, []string{"foo", "bar"}, s.Slice())
s.Remove("foo")
assert.ElementsMatch(t, []string{"bar"}, s.Slice())
}