1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

add more suggestions

This commit is contained in:
Jesse Duffield
2021-10-23 11:25:37 +11:00
parent 629494144f
commit ef544e6ce9
14 changed files with 239 additions and 35 deletions

View File

@ -165,3 +165,86 @@ 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
limit int
want []string
}{
{
values: []string{"a", "b", "c"},
limit: 3,
want: []string{"a", "b", "c"},
},
{
values: []string{"a", "b", "c"},
limit: 4,
want: []string{"a", "b", "c"},
},
{
values: []string{"a", "b", "c"},
limit: 2,
want: []string{"a", "b"},
},
{
values: []string{"a", "b", "c"},
limit: 1,
want: []string{"a"},
},
{
values: []string{"a", "b", "c"},
limit: 0,
want: []string{},
},
{
values: []string{},
limit: 0,
want: []string{},
},
} {
if got := Limit(test.values, test.limit); !assert.EqualValues(t, got, test.want) {
t.Errorf("Limit(%v, %d) = %v; want %v", test.values, test.limit, got, test.want)
}
}
}
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)
}
}
}