(t *testing.T)
| 385 | } |
| 386 | |
| 387 | func TestTreeRegexMatchWholeParam(t *testing.T) { |
| 388 | hStub1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 389 | |
| 390 | rctx := NewRouteContext() |
| 391 | tr := &node{} |
| 392 | tr.InsertRoute(mGET, "/{id:[0-9]+}", hStub1) |
| 393 | tr.InsertRoute(mGET, "/{x:.+}/foo", hStub1) |
| 394 | tr.InsertRoute(mGET, "/{param:[0-9]*}/test", hStub1) |
| 395 | |
| 396 | tests := []struct { |
| 397 | expectedHandler http.Handler |
| 398 | url string |
| 399 | }{ |
| 400 | {url: "/13", expectedHandler: hStub1}, |
| 401 | {url: "/a13", expectedHandler: nil}, |
| 402 | {url: "/13.jpg", expectedHandler: nil}, |
| 403 | {url: "/a13.jpg", expectedHandler: nil}, |
| 404 | {url: "/a/foo", expectedHandler: hStub1}, |
| 405 | {url: "//foo", expectedHandler: nil}, |
| 406 | {url: "//test", expectedHandler: hStub1}, |
| 407 | } |
| 408 | |
| 409 | for _, tc := range tests { |
| 410 | _, _, handler := tr.FindRoute(rctx, mGET, tc.url) |
| 411 | if fmt.Sprintf("%v", tc.expectedHandler) != fmt.Sprintf("%v", handler) { |
| 412 | t.Errorf("url %v: expecting handler:%v , got:%v", tc.url, tc.expectedHandler, handler) |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | func TestTreeFindPattern(t *testing.T) { |
| 418 | hStub1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
nothing calls this directly
no test coverage detected