Home / Function/ TestGetMapFromFormData() — gin Function Reference

TestGetMapFromFormData() — gin Function Reference

Architecture documentation for the TestGetMapFromFormData() function in context_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  d9d07a9a_6acf_be44_7c24_aa6879146cac["TestGetMapFromFormData()"]
  ebe0ae48_a62b_a38f_5bac_5bbbd96fc508["context_test.go"]
  d9d07a9a_6acf_be44_7c24_aa6879146cac -->|defined in| ebe0ae48_a62b_a38f_5bac_5bbbd96fc508
  style d9d07a9a_6acf_be44_7c24_aa6879146cac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

context_test.go lines 3540–3669

func TestGetMapFromFormData(t *testing.T) {
	testCases := []struct {
		name     string
		data     map[string][]string
		key      string
		expected map[string]string
		found    bool
	}{
		{
			name: "Basic bracket notation",
			data: map[string][]string{
				"ids[a]": {"hi"},
				"ids[b]": {"3.14"},
			},
			key: "ids",
			expected: map[string]string{
				"a": "hi",
				"b": "3.14",
			},
			found: true,
		},
		{
			name: "Mixed data with bracket notation",
			data: map[string][]string{
				"ids[a]":     {"hi"},
				"ids[b]":     {"3.14"},
				"names[a]":   {"mike"},
				"names[b]":   {"maria"},
				"other[key]": {"value"},
				"simple":     {"data"},
			},
			key: "ids",
			expected: map[string]string{
				"a": "hi",
				"b": "3.14",
			},
			found: true,
		},
		{
			name: "Names key",
			data: map[string][]string{
				"ids[a]":     {"hi"},
				"ids[b]":     {"3.14"},
				"names[a]":   {"mike"},
				"names[b]":   {"maria"},
				"other[key]": {"value"},
			},
			key: "names",
			expected: map[string]string{
				"a": "mike",
				"b": "maria",
			},
			found: true,
		},
		{
			name: "Key not found",
			data: map[string][]string{
				"ids[a]":   {"hi"},
				"names[b]": {"maria"},
			},
			key:      "notfound",
			expected: map[string]string{},
			found:    false,
		},
		{
			name:     "Empty data",
			data:     map[string][]string{},
			key:      "ids",
			expected: map[string]string{},
			found:    false,
		},
		{
			name: "Malformed bracket notation",
			data: map[string][]string{
				"ids[a": {"hi"},    // Missing closing bracket
				"ids]b": {"3.14"},  // Missing opening bracket
				"idsab": {"value"}, // No brackets
			},
			key:      "ids",
			expected: map[string]string{},
			found:    false,

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestGetMapFromFormData() do?
TestGetMapFromFormData() is a function in the gin codebase, defined in context_test.go.
Where is TestGetMapFromFormData() defined?
TestGetMapFromFormData() is defined in context_test.go at line 3540.

Analyze Your Own Codebase

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

Try Supermodel Free