2
0

[pool] Increase test coverage

This commit is contained in:
Jan Dubsky
2022-10-10 22:32:41 +02:00
committed by Jack Christensen
parent 89668fae42
commit 3009dbab62
6 changed files with 221 additions and 38 deletions
+41
View File
@@ -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]),