Home / Function/ TestRemoveRepeatedChar() — gin Function Reference

TestRemoveRepeatedChar() — gin Function Reference

Architecture documentation for the TestRemoveRepeatedChar() function in path_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

path_test.go lines 147–192

func TestRemoveRepeatedChar(t *testing.T) {
	testCases := []struct {
		name string
		str  string
		char byte
		want string
	}{
		{
			name: "empty",
			str:  "",
			char: 'a',
			want: "",
		},
		{
			name: "noSlash",
			str:  "abc",
			char: ',',
			want: "abc",
		},
		{
			name: "withSlash",
			str:  "/a/b/c/",
			char: '/',
			want: "/a/b/c/",
		},
		{
			name: "withRepeatedSlashes",
			str:  "/a//b///c////",
			char: '/',
			want: "/a/b/c/",
		},
		{
			name: "threeSlashes",
			str:  "///",
			char: '/',
			want: "/",
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			res := removeRepeatedChar(tc.str, tc.char)
			assert.Equal(t, tc.want, res)
		})
	}
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free