From 91056bca792ce59e8c8caae59b7a20c3349ae79f Mon Sep 17 00:00:00 2001 From: kim Date: Fri, 8 Nov 2024 14:35:23 +0000 Subject: [PATCH] improved xslices tests --- internal/util/xslices/slices_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/util/xslices/slices_test.go b/internal/util/xslices/slices_test.go index ad4fb3519..d4c87ba53 100644 --- a/internal/util/xslices/slices_test.go +++ b/internal/util/xslices/slices_test.go @@ -33,6 +33,9 @@ func TestGrowJust(t *testing.T) { for _, g := range []int{0, 2, 4, 8, 16, 32, 64} { s2 := xslices.GrowJust(s, g) + // Slice length should not be different. + assert.Equal(t, len(s), len(s2)) + switch { // If slice already has capacity for // 'g' then it should not be changed. @@ -58,6 +61,9 @@ func TestAppendJust(t *testing.T) { toAppend := make([]int, a) s2 := xslices.AppendJust(s, toAppend...) + // Slice length should be as expected. + assert.Equal(t, len(s2), len(s)+a) + switch { // If slice already has capacity for // 'toAppend' then it should not change. @@ -68,7 +74,7 @@ func TestAppendJust(t *testing.T) { // have capacity for original length // plus extra elements, NOTHING MORE. default: - assert.Equal(t, cap(s2), len(s)+len(toAppend)) + assert.Equal(t, cap(s2), len(s)+a) } } }