1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

make more use of generics

This commit is contained in:
Jesse Duffield
2022-03-19 12:26:30 +11:00
parent dde30fa104
commit c7a629c440
52 changed files with 3013 additions and 274 deletions

View File

@ -6,42 +6,6 @@ import (
"github.com/stretchr/testify/assert"
)
// TestIncludesString is a function.
func TestIncludesString(t *testing.T) {
type scenario struct {
list []string
element string
expected bool
}
scenarios := []scenario{
{
[]string{"a", "b"},
"a",
true,
},
{
[]string{"a", "b"},
"c",
false,
},
{
[]string{"a", "b"},
"",
false,
},
{
[]string{""},
"",
true,
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, IncludesString(s.list, s.element))
}
}
func TestNextIndex(t *testing.T) {
type scenario struct {
testName string
@ -169,26 +133,6 @@ func TestEscapeSpecialChars(t *testing.T) {
}
}
func TestUniq(t *testing.T) {
for _, test := range []struct {
values []string
want []string
}{
{
values: []string{"a", "b", "c"},
want: []string{"a", "b", "c"},
},
{
values: []string{"a", "b", "a", "b", "c"},
want: []string{"a", "b", "c"},
},
} {
if got := Uniq(test.values); !assert.EqualValues(t, got, test.want) {
t.Errorf("Uniq(%v) = %v; want %v", test.values, got, test.want)
}
}
}
func TestLimit(t *testing.T) {
for _, test := range []struct {
values []string
@ -232,26 +176,6 @@ func TestLimit(t *testing.T) {
}
}
func TestReverse(t *testing.T) {
for _, test := range []struct {
values []string
want []string
}{
{
values: []string{"a", "b", "c"},
want: []string{"c", "b", "a"},
},
{
values: []string{},
want: []string{},
},
} {
if got := Reverse(test.values); !assert.EqualValues(t, got, test.want) {
t.Errorf("Reverse(%v) = %v; want %v", test.values, got, test.want)
}
}
}
func TestLimitStr(t *testing.T) {
for _, test := range []struct {
values string