Skip to content

Commit

Permalink
[update] add test case for regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
bmf-san committed Jul 14, 2023
1 parent 7af2527 commit b3e16a1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ func TestSearchRegexp(t *testing.T) {
fooBarHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
fooBarIDHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
fooBarIDNameHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
bazInvalidIDHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})

tree.Insert(`/`, rootHandler, []middleware{first})
tree.Insert(`/:*[(.+)]`, rootWildCardHandler, []middleware{first})
Expand All @@ -714,6 +715,7 @@ func TestSearchRegexp(t *testing.T) {
tree.Insert(`/foo/bar`, fooBarHandler, []middleware{first})
tree.Insert(`/foo/bar/:id`, fooBarIDHandler, []middleware{first})
tree.Insert(`/foo/bar/:id/:name`, fooBarIDNameHandler, []middleware{first})
tree.Insert(`/baz/:id[[\d+]`, bazInvalidIDHandler, []middleware{first})

cases := []caseWithFailure{
{
Expand Down Expand Up @@ -885,6 +887,14 @@ func TestSearchRegexp(t *testing.T) {
},
},
},
{
hasError: true,
item: &item{
path: "/baz/1",
},
expectedAction: nil,
expectedParams: Params{},
},
}

testWithFailure(t, tree, cases)
Expand Down

0 comments on commit b3e16a1

Please sign in to comment.