@@ -11,6 +11,8 @@ import (
1111 "github.com/stretchr/testify/assert"
1212)
1313
14+ var MaxHandlers = 32
15+
1416func init () {
1517 SetMode (TestMode )
1618}
@@ -193,3 +195,25 @@ func testRoutesInterface(t *testing.T, r IRoutes) {
193195 assert .Equal (t , r , r .Static ("/static" , "." ))
194196 assert .Equal (t , r , r .StaticFS ("/static2" , Dir ("." , false )))
195197}
198+
199+ func TestRouterGroupCombineHandlersTooManyHandlers (t * testing.T ) {
200+ group := & RouterGroup {
201+ Handlers : make (HandlersChain , MaxHandlers ), // Assume group already has MaxHandlers middleware
202+ }
203+ tooManyHandlers := make (HandlersChain , MaxHandlers ) // Add MaxHandlers more, total 2 * MaxHandlers
204+
205+ // This should trigger panic
206+ assert .Panics (t , func () {
207+ group .combineHandlers (tooManyHandlers )
208+ }, "should panic due to too many handlers" )
209+ }
210+
211+ func TestRouterGroupCombineHandlersEmptySliceNotNil (t * testing.T ) {
212+ group := & RouterGroup {
213+ Handlers : HandlersChain {},
214+ }
215+
216+ result := group .combineHandlers (HandlersChain {})
217+ assert .NotNil (t , result , "result should not be nil even with empty handlers" )
218+ assert .Empty (t , result , "empty handlers should return empty chain" )
219+ }
0 commit comments