added TestInsertOrShift

This commit is contained in:
Alfred Kamanda 2025-02-04 11:42:14 +03:00
parent ff3c597158
commit c78081fb84
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703

42
profile/profile_test.go Normal file
View File

@ -0,0 +1,42 @@
package profile
import (
"testing"
"github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
func TestInsertOrShift(t *testing.T) {
tests := []struct {
name string
profile Profile
index int
value string
expected []string
}{
{
name: "Insert within range",
profile: Profile{ProfileItems: []string{"A", "B", "C"}, Max: 5},
index: 1,
value: "X",
expected: []string{"A", "X"},
},
{
name: "Insert beyond range",
profile: Profile{ProfileItems: []string{"A"}, Max: 5},
index: 3,
value: "Y",
expected: []string{"A", "0", "0", "Y"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := tt.profile
p.InsertOrShift(tt.index, tt.value)
require.NotNil(t, p.ProfileItems)
assert.Equal(t, tt.expected, p.ProfileItems)
})
}
}