Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
foolin committed Apr 25, 2020
1 parent e0275e4 commit 6ad6132
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ package pagser
import "testing"

func TestToInt32SliceE(t *testing.T) {
_, err := toInt32SliceE(nil)
if err == nil {
t.Fatal("nil not return error")
}

_, err = toInt32SliceE(1)
if err == nil {
t.Fatal("1 not return error")
}

list := []int32{1, 2, 3}
out, err := toInt32SliceE(list)
t.Logf("out: %v, error: %v", out, err)
}

func TestToInt64SliceE(t *testing.T) {
_, err := toInt64SliceE(nil)
if err == nil {
t.Fatal("nil not return error")
}

_, err = toInt64SliceE(1)
if err == nil {
t.Fatal("1 not return error")
}

list := []int64{1, 2, 3}
out, err := toInt64SliceE(list)
t.Logf("out: %v, error: %v", out, err)
}

func TestToFloat32SliceE(t *testing.T) {
_, err := toFloat32SliceE(nil)
if err == nil {
t.Fatal("nil not return error")
Expand All @@ -13,8 +45,23 @@ func TestToInt32SliceE(t *testing.T) {
t.Fatal("1 not return error")
}

arrs := []int32{1, 2, 3}
out, err := toFloat32SliceE(arrs)
list := []float32{1, 2, 3}
out, err := toFloat32SliceE(list)
t.Logf("out: %v, error: %v", out, err)
}

func TestToFloat64SliceE(t *testing.T) {
_, err := toFloat64SliceE(nil)
if err == nil {
t.Fatal("nil not return error")
}

_, err = toFloat64SliceE(1)
if err == nil {
t.Fatal("1 not return error")
}

list := []float64{1, 2, 3}
out, err := toFloat64SliceE(list)
t.Logf("out: %v, error: %v", out, err)
}

0 comments on commit 6ad6132

Please sign in to comment.