Files
baseapi/utils/typeconv_test.go
gazebo 4fa834f839 - mtwm.OrderLogisticsChange2Self
- TryInterface2xx
2019-03-27 11:20:11 +08:00

33 lines
472 B
Go

package utils
import (
"encoding/json"
"testing"
)
func TestConv(t *testing.T) {
for _, v := range [][]interface{}{
[]interface{}{
json.Number("123"),
int64(123),
},
[]interface{}{
json.Number("abc"),
int64(0),
},
[]interface{}{
"123",
int64(0),
},
[]interface{}{
int64(123),
int64(123),
},
} {
data := Interface2Int64WithDefault(v[0], 0)
if data != v[1].(int64) {
t.Fatal("Interface2Int64WithDefault failed")
}
}
}