Home / Function/ Test_XMLBinding_Bind() — fiber Function Reference

Test_XMLBinding_Bind() — fiber Function Reference

Architecture documentation for the Test_XMLBinding_Bind() function in xml_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  28d8c134_d08f_b40b_6727_bfd04347c809["Test_XMLBinding_Bind()"]
  52b651c2_43d7_4d18_ee75_f95d21b8b05d["xml_test.go"]
  28d8c134_d08f_b40b_6727_bfd04347c809 -->|defined in| 52b651c2_43d7_4d18_ee75_f95d21b8b05d
  style 28d8c134_d08f_b40b_6727_bfd04347c809 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binder/xml_test.go lines 10–57

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)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_XMLBinding_Bind() do?
Test_XMLBinding_Bind() is a function in the fiber codebase, defined in binder/xml_test.go.
Where is Test_XMLBinding_Bind() defined?
Test_XMLBinding_Bind() is defined in binder/xml_test.go at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free