Home / Function/ Test_Ctx_Range() — fiber Function Reference

Test_Ctx_Range() — fiber Function Reference

Architecture documentation for the Test_Ctx_Range() function in ctx_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  55454bef_a5f0_776d_b0e7_6f873acd5132["Test_Ctx_Range()"]
  7b3d4933_5ae3_f84d_ff6d_0cb34e268026["ctx_test.go"]
  55454bef_a5f0_776d_b0e7_6f873acd5132 -->|defined in| 7b3d4933_5ae3_f84d_ff6d_0cb34e268026
  style 55454bef_a5f0_776d_b0e7_6f873acd5132 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

ctx_test.go lines 4133–4166

func Test_Ctx_Range(t *testing.T) {
	t.Parallel()
	app := New()
	c := app.AcquireCtx(&fasthttp.RequestCtx{})

	testRange := func(header string, ranges ...RangeSet) {
		c.Request().Header.Set(HeaderRange, header)
		result, err := c.Range(1000)
		if len(ranges) == 0 {
			require.Error(t, err)
		} else {
			require.Equal(t, "bytes", result.Type)
			require.NoError(t, err)
		}
		require.Len(t, ranges, len(result.Ranges))
		for i := range ranges {
			require.Equal(t, ranges[i], result.Ranges[i])
		}
	}

	testRange("bytes=500")
	testRange("bytes=")
	testRange("bytes=500=")
	testRange("bytes=500-300")
	testRange("bytes=a-700", RangeSet{Start: 300, End: 999})
	testRange("bytes=500-b", RangeSet{Start: 500, End: 999})
	testRange("bytes=500-1000", RangeSet{Start: 500, End: 999})
	testRange("bytes=500-700", RangeSet{Start: 500, End: 700})
	testRange("bytes=0-0,2-1000", RangeSet{Start: 0, End: 0}, RangeSet{Start: 2, End: 999})
	testRange("bytes=0-99,450-549,-100", RangeSet{Start: 0, End: 99}, RangeSet{Start: 450, End: 549}, RangeSet{Start: 900, End: 999})
	testRange("bytes=500-700,601-999", RangeSet{Start: 500, End: 700}, RangeSet{Start: 601, End: 999})
	testRange("bytes= 0-1", RangeSet{Start: 0, End: 1})
	testRange("seconds=0-1")
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_Ctx_Range() do?
Test_Ctx_Range() is a function in the fiber codebase, defined in ctx_test.go.
Where is Test_Ctx_Range() defined?
Test_Ctx_Range() is defined in ctx_test.go at line 4133.

Analyze Your Own Codebase

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

Try Supermodel Free