Home / File/ xml_test.go — fiber Source File

xml_test.go — fiber Source File

Architecture documentation for xml_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go DataBinding PayloadParsers 1 imports 3 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  52b651c2_43d7_4d18_ee75_f95d21b8b05d["xml_test.go"]
  a929cecf_caa1_19ce_c9df_59387f3e5e11["xml"]
  52b651c2_43d7_4d18_ee75_f95d21b8b05d --> a929cecf_caa1_19ce_c9df_59387f3e5e11
  style 52b651c2_43d7_4d18_ee75_f95d21b8b05d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package binder

import (
	"encoding/xml"
	"testing"

	"github.com/stretchr/testify/require"
)

func Test_XMLBinding_Bind(t *testing.T) {
	t.Parallel()

	b := &XMLBinding{
		XMLDecoder: xml.Unmarshal,
	}
	require.Equal(t, "xml", b.Name())

	type Posts struct {
		XMLName xml.Name `xml:"post"`
		Title   string   `xml:"title"`
	}

	type User struct {
		Name   string  `xml:"name"`
		Ignore string  `xml:"-"`
		Posts  []Posts `xml:"posts>post"`
		Age    int     `xml:"age"`
	}

	user := new(User)
	err := b.Bind([]byte(`
		<user>
			<name>john</name>
			<age>42</age>
			<ignore>ignore</ignore>
			<posts>
				<post>
					<title>post1</title>
				</post>
				<post>
					<title>post2</title>
				</post>
			</posts>
		</user>
	`), user)
	require.NoError(t, err)
	require.Equal(t, "john", user.Name)
	require.Equal(t, 42, user.Age)
	require.Empty(t, user.Ignore)

	require.Len(t, user.Posts, 2)
	require.Equal(t, "post1", user.Posts[0].Title)
	require.Equal(t, "post2", user.Posts[1].Title)

	b.Reset()
	require.Nil(t, b.XMLDecoder)
}

func Test_XMLBinding_Bind_error(t *testing.T) {
	t.Parallel()
// ... (74 more lines)

Domain

Subdomains

Classes

Dependencies

  • xml

Frequently Asked Questions

What does xml_test.go do?
xml_test.go is a source file in the fiber codebase, written in go. It belongs to the DataBinding domain, PayloadParsers subdomain.
What functions are defined in xml_test.go?
xml_test.go defines 3 function(s): Benchmark_XMLBinding_Bind, Test_XMLBinding_Bind, Test_XMLBinding_Bind_error.
What does xml_test.go depend on?
xml_test.go imports 1 module(s): xml.
Where is xml_test.go in the architecture?
xml_test.go is located at binder/xml_test.go (domain: DataBinding, subdomain: PayloadParsers, directory: binder).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free