1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-22 05:12:49 +00:00

💯 improve path.go coverage

This commit is contained in:
kiyon 2020-07-09 15:51:04 +08:00
parent 6467e41889
commit 96371a2869
2 changed files with 23 additions and 1 deletions

View File

@ -239,7 +239,7 @@ func getAllocFreeParamsPos(allocLen int) [][2]int {
func getAllocFreeParams(allocLen int) []string {
size := uint32(allocLen)
start := atomic.AddUint32(&startParamList, size)
if (start + 10) >= uint32(len(paramsPosDummy)) {
if (start + 10) >= uint32(len(paramsDummy)) {
atomic.StoreUint32(&startParamList, 0)
return getAllocFreeParams(allocLen)
}

View File

@ -198,3 +198,25 @@ func Test_Path_matchParams(t *testing.T) {
{url: "xyz/", params: nil, match: false},
})
}
// go test -race -run Test_Reset_StartParamPosList
func Test_Reset_StartParamPosList(t *testing.T) {
t.Parallel()
startParamPosList = uint32(len(paramsPosDummy)) - 10
getAllocFreeParamsPos(5)
utils.AssertEqual(t, uint32(5), startParamPosList)
}
// go test -race -run Test_Reset_startParamList
func Test_Reset_startParamList(t *testing.T) {
t.Parallel()
startParamList = uint32(len(paramsDummy)) - 10
getAllocFreeParams(5)
utils.AssertEqual(t, uint32(5), startParamList)
}