refactor(struct): Remove redundant type conversions (#3345)
This commit is contained in:
parent
45c758e2f9
commit
33ab0fc155
@ -1107,9 +1107,7 @@ func testFormBindingForType(t *testing.T, method, path, badPath, body, badBody s
|
|||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
struct {
|
struct {
|
||||||
Idx int "form:\"idx\""
|
Idx int "form:\"idx\""
|
||||||
}(struct {
|
}{Idx: 123},
|
||||||
Idx int "form:\"idx\""
|
|
||||||
}{Idx: 123}),
|
|
||||||
obj.StructFoo)
|
obj.StructFoo)
|
||||||
case "StructPointer":
|
case "StructPointer":
|
||||||
obj := FooStructForStructPointerType{}
|
obj := FooStructForStructPointerType{}
|
||||||
@ -1118,9 +1116,7 @@ func testFormBindingForType(t *testing.T, method, path, badPath, body, badBody s
|
|||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
struct {
|
struct {
|
||||||
Name string "form:\"name\""
|
Name string "form:\"name\""
|
||||||
}(struct {
|
}{Name: "thinkerou"},
|
||||||
Name string "form:\"name\""
|
|
||||||
}{Name: "thinkerou"}),
|
|
||||||
*obj.StructPointerFoo)
|
*obj.StructPointerFoo)
|
||||||
case "Map":
|
case "Map":
|
||||||
obj := FooStructForMapType{}
|
obj := FooStructForMapType{}
|
||||||
|
@ -114,7 +114,7 @@ func TestMappingPrivateField(t *testing.T) {
|
|||||||
}
|
}
|
||||||
err := mappingByPtr(&s, formSource{"field": {"6"}}, "form")
|
err := mappingByPtr(&s, formSource{"field": {"6"}}, "form")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, int(0), s.f)
|
assert.Equal(t, 0, s.f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMappingUnknownFieldType(t *testing.T) {
|
func TestMappingUnknownFieldType(t *testing.T) {
|
||||||
@ -133,7 +133,7 @@ func TestMappingURI(t *testing.T) {
|
|||||||
}
|
}
|
||||||
err := mapURI(&s, map[string][]string{"field": {"6"}})
|
err := mapURI(&s, map[string][]string{"field": {"6"}})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, int(6), s.F)
|
assert.Equal(t, 6, s.F)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMappingForm(t *testing.T) {
|
func TestMappingForm(t *testing.T) {
|
||||||
@ -142,7 +142,7 @@ func TestMappingForm(t *testing.T) {
|
|||||||
}
|
}
|
||||||
err := mapForm(&s, map[string][]string{"field": {"6"}})
|
err := mapForm(&s, map[string][]string{"field": {"6"}})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, int(6), s.F)
|
assert.Equal(t, 6, s.F)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMapFormWithTag(t *testing.T) {
|
func TestMapFormWithTag(t *testing.T) {
|
||||||
@ -151,7 +151,7 @@ func TestMapFormWithTag(t *testing.T) {
|
|||||||
}
|
}
|
||||||
err := MapFormWithTag(&s, map[string][]string{"field": {"6"}}, "externalTag")
|
err := MapFormWithTag(&s, map[string][]string{"field": {"6"}}, "externalTag")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, int(6), s.F)
|
assert.Equal(t, 6, s.F)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMappingTime(t *testing.T) {
|
func TestMappingTime(t *testing.T) {
|
||||||
|
@ -173,7 +173,7 @@ func TestRenderAsciiJSON(t *testing.T) {
|
|||||||
assert.Equal(t, "application/json", w1.Header().Get("Content-Type"))
|
assert.Equal(t, "application/json", w1.Header().Get("Content-Type"))
|
||||||
|
|
||||||
w2 := httptest.NewRecorder()
|
w2 := httptest.NewRecorder()
|
||||||
data2 := float64(3.1415926)
|
data2 := 3.1415926
|
||||||
|
|
||||||
err = (AsciiJSON{data2}).Render(w2)
|
err = (AsciiJSON{data2}).Render(w2)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user