[pool] Increase test coverage
This commit is contained in:
committed by
Jack Christensen
parent
89668fae42
commit
3009dbab62
@@ -4,8 +4,49 @@ 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]),
|
||||
|
||||
Reference in New Issue
Block a user