-
Notifications
You must be signed in to change notification settings - Fork 3
/
slice_test.go
28 lines (24 loc) · 976 Bytes
/
slice_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package convert_test
import (
"testing"
"github.com/Eun/go-convert/internal/testhelpers"
)
func TestSlice(t *testing.T) {
tests := []testhelpers.TestCase{
{nil, []int{}, []int{}, "", nil},
{6, []int{}, []int{}, "unable to convert int to []int: no recipe", nil},
{[]interface{}{[]int{}}, []int{}, []int{}, "unable to convert []interface {} to []int: unable to convert []int to int: no recipe", nil},
// string
{"Hello World", []byte{}, []byte("Hello World"), "", nil},
{"Hello", []int{}, []int{'H', 'e', 'l', 'l', 'o'}, "", nil},
{"Hello", []string{}, []string{}, "unable to convert string to []string: no recipe", nil},
{"", []byte{}, []byte{}, "", nil},
// Slice to Slice
{[]int{1, 2, 3}, []uint{}, []uint{1, 2, 3}, "", nil},
{[]int{1, 2, 3}, []string{}, []string{"1", "2", "3"}, "", nil},
{[]int{1, 2, 3}, []interface{}{"", 0.0, 0}, []interface{}{"1", 2.0, 3}, "", nil},
}
for i, test := range tests {
testhelpers.RunTest(t, test, i)
}
}