(t *testing.T)
| 415 | } |
| 416 | |
| 417 | func TestTreeFindPattern(t *testing.T) { |
| 418 | hStub1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 419 | hStub2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 420 | hStub3 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 421 | |
| 422 | tr := &node{} |
| 423 | tr.InsertRoute(mGET, "/pages/*", hStub1) |
| 424 | tr.InsertRoute(mGET, "/articles/{id}/*", hStub2) |
| 425 | tr.InsertRoute(mGET, "/articles/{slug}/{uid}/*", hStub3) |
| 426 | |
| 427 | if tr.findPattern("/pages") != false { |
| 428 | t.Errorf("find /pages failed") |
| 429 | } |
| 430 | if tr.findPattern("/pages*") != false { |
| 431 | t.Errorf("find /pages* failed - should be nil") |
| 432 | } |
| 433 | if tr.findPattern("/pages/*") == false { |
| 434 | t.Errorf("find /pages/* failed") |
| 435 | } |
| 436 | if tr.findPattern("/articles/{id}/*") == false { |
| 437 | t.Errorf("find /articles/{id}/* failed") |
| 438 | } |
| 439 | if tr.findPattern("/articles/{something}/*") == false { |
| 440 | t.Errorf("find /articles/{something}/* failed") |
| 441 | } |
| 442 | if tr.findPattern("/articles/{slug}/{uid}/*") == false { |
| 443 | t.Errorf("find /articles/{slug}/{uid}/* failed") |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | func debugPrintTree(parent int, i int, n *node, label byte) bool { |
| 448 | numEdges := 0 |
nothing calls this directly
no test coverage detected