-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathresource_list_test.go
More file actions
62 lines (48 loc) · 1.08 KB
/
resource_list_test.go
File metadata and controls
62 lines (48 loc) · 1.08 KB
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
60
61
62
package puddle
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResList_Append(t *testing.T) {
r := require.New(t)
arr := []*Resource[any]{
new(Resource[any]),
new(Resource[any]),
new(Resource[any]),
}
list := resList[any](arr)
list.append(new(Resource[any]))
r.Len(list, 4)
list.append(new(Resource[any]))
r.Len(list, 5)
list.append(new(Resource[any]))
r.Len(list, 6)
}
func TestResList_PopBack(t *testing.T) {
r := require.New(t)
arr := []*Resource[any]{
new(Resource[any]),
new(Resource[any]),
new(Resource[any]),
}
list := resList[any](arr)
list.popBack()
r.Len(list, 2)
list.popBack()
r.Len(list, 1)
list.popBack()
r.Len(list, 0)
r.Panics(func() { list.popBack() })
}
func TestResList_PanicsWithBugReportIfResourceDoesNotExist(t *testing.T) {
arr := []*Resource[any]{
new(Resource[any]),
new(Resource[any]),
new(Resource[any]),
}
list := resList[any](arr)
assert.PanicsWithValue(t, "BUG: removeResource could not find res in slice", func() {
list.remove(new(Resource[any]))
})
}