...
1 package stringslice
2
3 import (
4 "fmt"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestReverse(t *testing.T) {
11 for i, tc := range []struct {
12 i, e []string
13 }{
14 {
15 i: []string{"a", "b", "c"},
16 e: []string{"c", "b", "a"},
17 },
18 {
19 i: []string{"foo"},
20 e: []string{"foo"},
21 },
22 {
23 i: []string{"foo", "bar"},
24 e: []string{"bar", "foo"},
25 },
26 {
27 i: []string{},
28 e: []string{},
29 },
30 } {
31 t.Run(fmt.Sprintf("case=%d/input:%v expected:%v", i, tc.i, tc.e), func(t *testing.T) {
32 assert.Equal(t, tc.e, Reverse(tc.i))
33 })
34 }
35 }
36
View as plain text