mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-04 14:49:27 +08:00
test: add direct node evaluation test to achieve 100% patch coverage in tree.go
This commit is contained in:
parent
ce65d64ef5
commit
53f7c79e66
@ -3992,7 +3992,13 @@ func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for _, p := range paths {
|
||||
req, _ := http.NewRequest(http.MethodGet, p, nil)
|
||||
req, err := http.NewRequest(http.MethodGet, p, nil)
|
||||
if err != nil {
|
||||
mu.Lock()
|
||||
errs = append(errs, "failed to create request: " + err.Error())
|
||||
mu.Unlock()
|
||||
continue
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
|
||||
17
tree_test.go
17
tree_test.go
@ -1111,3 +1111,20 @@ func TestTreeFindCaseInsensitivePathWildcardParamAndStaticChild(t *testing.T) {
|
||||
t.Errorf("Wrong result for '/prefix/something': %s", string(out))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeWildcardParamImproperBoundaryCoverage(t *testing.T) {
|
||||
tree := &node{}
|
||||
|
||||
// Register a path with a wild named parameter segment
|
||||
tree.addRoute("/submit/:info", HandlersChain{func(c *Context) {}})
|
||||
|
||||
// Pass a path containing a multi-byte sequence where a standard byte segment lookup
|
||||
// drifts directly into the middle of a continuation block.
|
||||
// This exercises our inner boundary alignment decrement loop.
|
||||
path := "/submit/जय"
|
||||
value := tree.getValue(path, &Params{}, nil, false)
|
||||
|
||||
if value.handlers == nil {
|
||||
t.Errorf("Routing fallback failed on multi-byte parameter verification evaluation.")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user