Home / Function/ TestSliceValidationError() — gin Function Reference

TestSliceValidationError() — gin Function Reference

Architecture documentation for the TestSliceValidationError() function in default_validator_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  81e523a5_27ed_c67a_f08b_05c0325cb1b5["TestSliceValidationError()"]
  112d05ac_bbed_3a94_7047_a9b96d252a3c["default_validator_test.go"]
  81e523a5_27ed_c67a_f08b_05c0325cb1b5 -->|defined in| 112d05ac_bbed_3a94_7047_a9b96d252a3c
  style 81e523a5_27ed_c67a_f08b_05c0325cb1b5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/default_validator_test.go lines 12–49

func TestSliceValidationError(t *testing.T) {
	tests := []struct {
		name string
		err  SliceValidationError
		want string
	}{
		{"has nil elements", SliceValidationError{errors.New("test error"), nil}, "[0]: test error"},
		{"has zero elements", SliceValidationError{}, ""},
		{"has one element", SliceValidationError{errors.New("test one error")}, "[0]: test one error"},
		{
			"has two elements",
			SliceValidationError{
				errors.New("first error"),
				errors.New("second error"),
			},
			"[0]: first error\n[1]: second error",
		},
		{
			"has many elements",
			SliceValidationError{
				errors.New("first error"),
				errors.New("second error"),
				nil,
				nil,
				nil,
				errors.New("last error"),
			},
			"[0]: first error\n[1]: second error\n[5]: last error",
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := tt.err.Error(); got != tt.want {
				t.Errorf("SliceValidationError.Error() = %v, want %v", got, tt.want)
			}
		})
	}
}

Subdomains

Frequently Asked Questions

What does TestSliceValidationError() do?
TestSliceValidationError() is a function in the gin codebase, defined in binding/default_validator_test.go.
Where is TestSliceValidationError() defined?
TestSliceValidationError() is defined in binding/default_validator_test.go at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free