@@ -874,6 +874,42 @@ func TestRouterParamAlias(t *testing.T) {
874
874
testRouterAPI (t , api )
875
875
}
876
876
877
+ // Issue #1052
878
+ func TestRouterParamOrdering (t * testing.T ) {
879
+ api := []* Route {
880
+ {GET , "/:a/:b/:c/:id" , "" },
881
+ {GET , "/:a/:id" , "" },
882
+ {GET , "/:a/:e/:id" , "" },
883
+ }
884
+ testRouterAPI (t , api )
885
+ api2 := []* Route {
886
+ {GET , "/:a/:id" , "" },
887
+ {GET , "/:a/:e/:id" , "" },
888
+ {GET , "/:a/:b/:c/:id" , "" },
889
+ }
890
+ testRouterAPI (t , api2 )
891
+ api3 := []* Route {
892
+ {GET , "/:a/:b/:c/:id" , "" },
893
+ {GET , "/:a/:e/:id" , "" },
894
+ {GET , "/:a/:id" , "" },
895
+ }
896
+ testRouterAPI (t , api3 )
897
+ }
898
+
899
+ // Issue #1139
900
+ func TestRouterMixedParams (t * testing.T ) {
901
+ api := []* Route {
902
+ {GET , "/teacher/:tid/room/suggestions" , "" },
903
+ {GET , "/teacher/:id" , "" },
904
+ }
905
+ testRouterAPI (t , api )
906
+ api2 := []* Route {
907
+ {GET , "/teacher/:id" , "" },
908
+ {GET , "/teacher/:tid/room/suggestions" , "" },
909
+ }
910
+ testRouterAPI (t , api2 )
911
+ }
912
+
877
913
func benchmarkRouterRoutes (b * testing.B , routes []* Route ) {
878
914
e := New ()
879
915
r := e .router
@@ -914,7 +950,7 @@ func BenchmarkRouterGooglePlusAPI(b *testing.B) {
914
950
915
951
func (n * node ) printTree (pfx string , tail bool ) {
916
952
p := prefix (tail , pfx , "└── " , "├── " )
917
- fmt .Printf ("%s%s, %p: type=%d, parent=%p, handler=%v\n " , p , n .prefix , n , n .kind , n .parent , n .methodHandler )
953
+ fmt .Printf ("%s%s, %p: type=%d, parent=%p, handler=%v, pnames=%v \n " , p , n .prefix , n , n .kind , n .parent , n .methodHandler , n . pnames )
918
954
919
955
children := n .children
920
956
l := len (children )
0 commit comments