MCPcopy
hub / github.com/gin-gonic/gin / TestRemoveRepeatedChar

Function TestRemoveRepeatedChar

path_test.go:147–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestRemoveRepeatedChar(t *testing.T) {
148 testCases := []struct {
149 name string
150 str string
151 char byte
152 want string
153 }{
154 {
155 name: "empty",
156 str: "",
157 char: 'a',
158 want: "",
159 },
160 {
161 name: "noSlash",
162 str: "abc",
163 char: ',',
164 want: "abc",
165 },
166 {
167 name: "withSlash",
168 str: "/a/b/c/",
169 char: '/',
170 want: "/a/b/c/",
171 },
172 {
173 name: "withRepeatedSlashes",
174 str: "/a//b///c////",
175 char: '/',
176 want: "/a/b/c/",
177 },
178 {
179 name: "threeSlashes",
180 str: "///",
181 char: '/',
182 want: "/",
183 },
184 }
185
186 for _, tc := range testCases {
187 t.Run(tc.name, func(t *testing.T) {
188 res := removeRepeatedChar(tc.str, tc.char)
189 assert.Equal(t, tc.want, res)
190 })
191 }
192}

Callers

nothing calls this directly

Calls 2

removeRepeatedCharFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected