1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00

improve unit testing cases

This commit is contained in:
John 2020-03-20 22:34:56 +08:00
parent e57942b374
commit 7881b2dee4
15 changed files with 36 additions and 36 deletions

View File

@ -541,13 +541,13 @@ func TestArray_RemoveValue(t *testing.T) {
}
func TestArray_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Array *garray.Array
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": []byte(`[1,2,3]`),
@ -558,7 +558,7 @@ func TestArray_UnmarshalValue(t *testing.T) {
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": g.Slice{1, 2, 3},

View File

@ -576,13 +576,13 @@ func TestIntArray_RemoveValue(t *testing.T) {
}
func TestIntArray_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Array *garray.IntArray
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": []byte(`[1,2,3]`),
@ -593,7 +593,7 @@ func TestIntArray_UnmarshalValue(t *testing.T) {
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": g.Slice{1, 2, 3},

View File

@ -579,13 +579,13 @@ func TestStrArray_RemoveValue(t *testing.T) {
}
func TestStrArray_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Array *garray.StrArray
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": []byte(`["1","2","3"]`),
@ -596,7 +596,7 @@ func TestStrArray_UnmarshalValue(t *testing.T) {
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"array": g.SliceStr{"1", "2", "3"},

View File

@ -365,13 +365,13 @@ func TestSet_AddIfNotExistFunc(t *testing.T) {
}
func TestSet_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Set *gset.Set
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"set": []byte(`["k1","k2","k3"]`),
@ -386,7 +386,7 @@ func TestSet_UnmarshalValue(t *testing.T) {
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"set": g.Slice{"k1", "k2", "k3"},

View File

@ -98,12 +98,12 @@ func Test_Bool_JSON(t *testing.T) {
}
func Test_Bool_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Bool
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "true",
@ -113,7 +113,7 @@ func Test_Bool_UnmarshalValue(t *testing.T) {
t.Assert(v.Var.Val(), true)
})
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "false",

View File

@ -60,12 +60,12 @@ func Test_Byte_JSON(t *testing.T) {
}
func Test_Byte_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Byte
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "2",

View File

@ -46,12 +46,12 @@ func Test_Bytes_JSON(t *testing.T) {
}
func Test_Bytes_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Bytes
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123",

View File

@ -47,12 +47,12 @@ func Test_Float32_JSON(t *testing.T) {
}
func Test_Float32_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Float32
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123.456",

View File

@ -45,12 +45,12 @@ func Test_Float64_JSON(t *testing.T) {
}
func Test_Float64_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Float64
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123.456",

View File

@ -58,12 +58,12 @@ func Test_Int32_JSON(t *testing.T) {
}
func Test_Int32_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Int32
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123",

View File

@ -57,12 +57,12 @@ func Test_Int64_JSON(t *testing.T) {
}
func Test_Int64_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Int64
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123",

View File

@ -57,12 +57,12 @@ func Test_Int_JSON(t *testing.T) {
}
func Test_Int_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Int
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123",

View File

@ -47,12 +47,12 @@ func Test_Interface_JSON(t *testing.T) {
}
func Test_Interface_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Var *gtype.Interface
}
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(map[string]interface{}{
"name": "john",
"var": "123",

View File

@ -31,13 +31,13 @@ func TestJson_UnmarshalJSON(t *testing.T) {
}
func TestJson_UnmarshalValue(t *testing.T) {
type Var struct {
type V struct {
Name string
Json *gjson.Json
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"json": []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`),
@ -52,7 +52,7 @@ func TestJson_UnmarshalValue(t *testing.T) {
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *Var
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"json": g.Map{

View File

@ -23,7 +23,7 @@ const (
// C creates an unit testing case.
// The parameter <t> is the pointer to testing.T of stdlib (*testing.T).
// The parameter <f> is the callback function for unit test case.
// The parameter <f> is the closure function for unit testing case.
func C(t *testing.T, f func(t *T)) {
defer func() {
if err := recover(); err != nil {
@ -36,7 +36,7 @@ func C(t *testing.T, f func(t *T)) {
// Case creates an unit testing case.
// The parameter <t> is the pointer to testing.T of stdlib (*testing.T).
// The parameter <f> is the callback function for unit test case.
// The parameter <f> is the closure function for unit testing case.
// Deprecated.
func Case(t *testing.T, f func()) {
defer func() {