xml_test.go 560 B

12345678910111213141516171819202122232425
  1. // Copyright 2019 Gin Core Team. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package binding
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/stretchr/testify/require"
  9. )
  10. func TestXMLBindingBindBody(t *testing.T) {
  11. var s struct {
  12. Foo string `xml:"foo"`
  13. }
  14. xmlBody := `<?xml version="1.0" encoding="UTF-8"?>
  15. <root>
  16. <foo>FOO</foo>
  17. </root>`
  18. err := xmlBinding{}.BindBody([]byte(xmlBody), &s)
  19. require.NoError(t, err)
  20. assert.Equal(t, "FOO", s.Foo)
  21. }