@@ -20,28 +20,31 @@ func generateHandler() fasthttp.RequestHandler {
20
20
func testHandlerAndParams (
21
21
t * testing.T , tree * Tree , requestedPath string , handler fasthttp.RequestHandler , wantTSR bool , params map [string ]interface {},
22
22
) {
23
- ctx := new (fasthttp.RequestCtx )
23
+ for _ , ctx := range [] * fasthttp. RequestCtx { new (fasthttp.RequestCtx ), nil } {
24
24
25
- h , tsr := tree .Get (requestedPath , ctx )
26
- if reflect .ValueOf (handler ).Pointer () != reflect .ValueOf (h ).Pointer () {
27
- t .Errorf ("Path '%s' handler == %p, want %p" , requestedPath , h , handler )
28
- }
25
+ h , tsr := tree .Get (requestedPath , ctx )
26
+ if reflect .ValueOf (handler ).Pointer () != reflect .ValueOf (h ).Pointer () {
27
+ t .Errorf ("Path '%s' handler == %p, want %p" , requestedPath , h , handler )
28
+ }
29
29
30
- if wantTSR != tsr {
31
- t .Errorf ("Path '%s' tsr == %v, want %v" , requestedPath , tsr , wantTSR )
32
- }
30
+ if wantTSR != tsr {
31
+ t .Errorf ("Path '%s' tsr == %v, want %v" , requestedPath , tsr , wantTSR )
32
+ }
33
33
34
- resultParams := make (map [string ]interface {})
35
- if params == nil {
36
- params = make (map [string ]interface {})
37
- }
34
+ if ctx != nil {
35
+ resultParams := make (map [string ]interface {})
36
+ if params == nil {
37
+ params = make (map [string ]interface {})
38
+ }
38
39
39
- ctx .VisitUserValues (func (key []byte , value interface {}) {
40
- resultParams [string (key )] = value
41
- })
40
+ ctx .VisitUserValues (func (key []byte , value interface {}) {
41
+ resultParams [string (key )] = value
42
+ })
42
43
43
- if ! reflect .DeepEqual (resultParams , params ) {
44
- t .Errorf ("User values == %v, want %v" , resultParams , params )
44
+ if ! reflect .DeepEqual (resultParams , params ) {
45
+ t .Errorf ("User values == %v, want %v" , resultParams , params )
46
+ }
47
+ }
45
48
}
46
49
}
47
50
0 commit comments