Home / Function/ TestPlainBinding() — gin Function Reference

TestPlainBinding() — gin Function Reference

Architecture documentation for the TestPlainBinding() function in binding_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  c8d74303_e67b_4b2c_eceb_819a2830adab["TestPlainBinding()"]
  2899e942_a23d_574e_8d47_d28e895c2604["requestWithBody()"]
  c8d74303_e67b_4b2c_eceb_819a2830adab -->|calls| 2899e942_a23d_574e_8d47_d28e895c2604
  style c8d74303_e67b_4b2c_eceb_819a2830adab fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/binding_test.go lines 1376–1404

func TestPlainBinding(t *testing.T) {
	p := Plain
	assert.Equal(t, "plain", p.Name())

	var s string
	req := requestWithBody(http.MethodPost, "/", "test string")
	require.NoError(t, p.Bind(req, &s))
	assert.Equal(t, "test string", s)

	var bs []byte
	req = requestWithBody(http.MethodPost, "/", "test []byte")
	require.NoError(t, p.Bind(req, &bs))
	assert.Equal(t, bs, []byte("test []byte"))

	var i int
	req = requestWithBody(http.MethodPost, "/", "test fail")
	require.Error(t, p.Bind(req, &i))

	req = requestWithBody(http.MethodPost, "/", "")
	req.Body = &failRead{}
	require.Error(t, p.Bind(req, &s))

	req = requestWithBody(http.MethodPost, "/", "")
	require.NoError(t, p.Bind(req, nil))

	var ptr *string
	req = requestWithBody(http.MethodPost, "/", "")
	require.NoError(t, p.Bind(req, ptr))
}

Domain

Subdomains

Frequently Asked Questions

What does TestPlainBinding() do?
TestPlainBinding() is a function in the gin codebase.
What does TestPlainBinding() call?
TestPlainBinding() calls 1 function(s): requestWithBody.

Analyze Your Own Codebase

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

Try Supermodel Free