(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func TestHasPartialMatchBoundary(t *testing.T) { |
| 180 | t.Parallel() |
| 181 | |
| 182 | testCases := []struct { |
| 183 | name string |
| 184 | path string |
| 185 | matchedLength int |
| 186 | expected bool |
| 187 | }{ |
| 188 | { |
| 189 | name: "negative length", |
| 190 | path: "/demo", |
| 191 | matchedLength: -1, |
| 192 | expected: false, |
| 193 | }, |
| 194 | { |
| 195 | name: "greater than length", |
| 196 | path: "/demo", |
| 197 | matchedLength: 6, |
| 198 | expected: false, |
| 199 | }, |
| 200 | { |
| 201 | name: "exact match", |
| 202 | path: "/demo", |
| 203 | matchedLength: len("/demo"), |
| 204 | expected: true, |
| 205 | }, |
| 206 | { |
| 207 | name: "zero length", |
| 208 | path: "/demo", |
| 209 | matchedLength: 0, |
| 210 | expected: false, |
| 211 | }, |
| 212 | { |
| 213 | name: "previous rune slash", |
| 214 | path: "/demo/child", |
| 215 | matchedLength: len("/demo/"), |
| 216 | expected: true, |
| 217 | }, |
| 218 | { |
| 219 | name: "next rune slash", |
| 220 | path: "/demo/child", |
| 221 | matchedLength: len("/demo"), |
| 222 | expected: true, |
| 223 | }, |
| 224 | { |
| 225 | name: "no boundary", |
| 226 | path: "/demo/child", |
| 227 | matchedLength: len("/dem"), |
| 228 | expected: false, |
| 229 | }, |
| 230 | } |
| 231 | |
| 232 | for _, testCase := range testCases { |
| 233 | t.Run(testCase.name, func(t *testing.T) { |
| 234 | t.Parallel() |
| 235 | require.Equal(t, testCase.expected, hasPartialMatchBoundary(testCase.path, testCase.matchedLength)) |
| 236 | }) |
nothing calls this directly
no test coverage detected