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
  d266be87_02b9_3071_8646_647db4c9d183["TestPlainBinding()"]
  314c6481_2bd0_e5a7_282c_94e41df6062a["binding_test.go"]
  d266be87_02b9_3071_8646_647db4c9d183 -->|defined in| 314c6481_2bd0_e5a7_282c_94e41df6062a
  aebd0564_565b_ba1b_7f92_4baaca0e7b7e["requestWithBody()"]
  d266be87_02b9_3071_8646_647db4c9d183 -->|calls| aebd0564_565b_ba1b_7f92_4baaca0e7b7e
  style d266be87_02b9_3071_8646_647db4c9d183 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))
}

Subdomains

Frequently Asked Questions

What does TestPlainBinding() do?
TestPlainBinding() is a function in the gin codebase, defined in binding/binding_test.go.
Where is TestPlainBinding() defined?
TestPlainBinding() is defined in binding/binding_test.go at line 1376.
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