Home / Function/ Test_SetValWithStruct() — fiber Function Reference

Test_SetValWithStruct() — fiber Function Reference

Architecture documentation for the Test_SetValWithStruct() function in request_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  377734ce_06d9_95c2_1126_fe80e20e8487["Test_SetValWithStruct()"]
  3cffa885_3458_eedf_a1f5_10f9dd0f3622["request_test.go"]
  377734ce_06d9_95c2_1126_fe80e20e8487 -->|defined in| 3cffa885_3458_eedf_a1f5_10f9dd0f3622
  style 377734ce_06d9_95c2_1126_fe80e20e8487 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/request_test.go lines 1590–1741

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

	// test SetValWithStruct via QueryParam struct.
	type args struct {
		TString   string
		TSlice    []string
		TIntSlice []int `param:"int_slice"`
		unexport  int
		TInt      int
		TUint     uint
		TFloat    float64
		TComplex  complex128
		TBool     bool
	}

	t.Run("the struct should be applied", func(t *testing.T) {
		t.Parallel()
		p := &QueryParam{
			Args: fasthttp.AcquireArgs(),
		}

		SetValWithStruct(p, "param", args{
			unexport:  5,
			TInt:      5,
			TUint:     5,
			TString:   "string",
			TFloat:    3.1,
			TComplex:  3 + 4i,
			TBool:     false,
			TSlice:    []string{"foo", "bar"},
			TIntSlice: []int{0, 1, 2},
		})

		require.Empty(t, string(p.Peek("unexport")))
		require.Equal(t, []byte("5"), p.Peek("TInt"))
		require.Equal(t, []byte("5"), p.Peek("TUint"))
		require.Equal(t, []byte("string"), p.Peek("TString"))
		require.Equal(t, []byte("3.1"), p.Peek("TFloat"))
		require.Equal(t, []byte("(3+4i)"), p.Peek("TComplex"))
		require.Equal(t, []byte("false"), p.Peek("TBool"))
		require.True(t, func() bool {
			for _, v := range p.PeekMulti("TSlice") {
				if string(v) == "foo" {
					return true
				}
			}
			return false
		}())

		require.True(t, func() bool {
			for _, v := range p.PeekMulti("TSlice") {
				if string(v) == "bar" {
					return true
				}
			}
			return false
		}())

		require.True(t, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "0" {
					return true
				}
			}
			return false
		}())

		require.True(t, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "1" {
					return true
				}
			}
			return false
		}())

		require.True(t, func() bool {
			for _, v := range p.PeekMulti("int_slice") {
				if string(v) == "2" {
					return true

Domain

Subdomains

Frequently Asked Questions

What does Test_SetValWithStruct() do?
Test_SetValWithStruct() is a function in the fiber codebase, defined in client/request_test.go.
Where is Test_SetValWithStruct() defined?
Test_SetValWithStruct() is defined in client/request_test.go at line 1590.

Analyze Your Own Codebase

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

Try Supermodel Free