MCPcopy
hub / github.com/gin-gonic/gin / TestEscapedColon

Function TestEscapedColon

gin_integration_test.go:584–607  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

582}
583
584func TestEscapedColon(t *testing.T) {
585 router := New()
586 f := func(u string) {
587 router.GET(u, func(c *Context) { c.String(http.StatusOK, u) })
588 }
589 f("/r/r\\:r")
590 f("/r/r:r")
591 f("/r/r/:r")
592 f("/r/r/\\:r")
593 f("/r/r/r\\:r")
594 assert.Panics(t, func() {
595 f("\\foo:")
596 })
597
598 router.updateRouteTrees()
599 ts := httptest.NewServer(router)
600 defer ts.Close()
601
602 testRequest(t, ts.URL+"/r/r123", "", "/r/r:r")
603 testRequest(t, ts.URL+"/r/r:r", "", "/r/r\\:r")
604 testRequest(t, ts.URL+"/r/r/r123", "", "/r/r/:r")
605 testRequest(t, ts.URL+"/r/r/:r", "", "/r/r/\\:r")
606 testRequest(t, ts.URL+"/r/r/r:r", "", "/r/r/r\\:r")
607}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
testRequestFunction · 0.85
updateRouteTreesMethod · 0.80
CloseMethod · 0.80
GETMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected