mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 18:22:23 +08:00
Merge 57100990b53952b608270ee0cc84d5ca96ee7204 into 783c7ee9c14eac0e65b501664b4f553291556b43
This commit is contained in:
commit
811d7035db
@ -15,6 +15,8 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO unit tests
|
// TODO unit tests
|
||||||
@ -128,30 +130,6 @@ func TestRenderSecureJSONFail(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
type xmlmap map[string]interface{}
|
|
||||||
|
|
||||||
// Allows type H to be used with xml.Marshal
|
|
||||||
func (h xmlmap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
||||||
start.Name = xml.Name{
|
|
||||||
Space: "",
|
|
||||||
Local: "map",
|
|
||||||
}
|
|
||||||
if err := e.EncodeToken(start); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for key, value := range h {
|
|
||||||
elem := xml.StartElement{
|
|
||||||
Name: xml.Name{Space: "", Local: key},
|
|
||||||
Attr: []xml.Attr{},
|
|
||||||
}
|
|
||||||
if err := e.EncodeElement(value, elem); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.EncodeToken(xml.EndElement{Name: start.Name})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRenderYAML(t *testing.T) {
|
func TestRenderYAML(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
data := `
|
data := `
|
||||||
@ -184,7 +162,7 @@ func TestRenderYAMLFail(t *testing.T) {
|
|||||||
|
|
||||||
func TestRenderXML(t *testing.T) {
|
func TestRenderXML(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
data := xmlmap{
|
data := gin.H{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user