Debian Codegraph @

strings_test.go

raw symbols SCIP
1 // ⚡️ Fiber is an Express-inspired web framework written in Go with ☕️
2 // 🤖 Github Repository: https://github.com/gofiber/fiber
3 // 📌 API Documentation: https://docs.gofiber.io
4
5 package utilsscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/
6
7 import (
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/"
11 )
12
13 func Test_AddTrailingSlashStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Test_AddTrailingSlashString().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
14 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
15
16 testCases := []struct {
17 name string
18 in string
19 want string
20 }{
21 {name: "empty", in: "", want: "/"},
22 {name: "slash-only", in: "/", want: "/"},
23 {name: "short-no-slash", in: "abc", want: "abc/"},
24 {name: "short-with-slash", in: "abc/", want: "abc/"},
25 {name: "path-no-slash", in: "/api/v1/users", want: "/api/v1/users/"},
26 {name: "path-with-slash", in: "/api/v1/users/", want: "/api/v1/users/"},
27 {name: "double-slash", in: "abc//", want: "abc//"},
28 {name: "unicode", in: "/日本語", want: "/日本語/"},
29 }
30
31 for _, tc := range testCases {
32 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
33 t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().()
34 result := AddTrailingSlashStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/AddTrailingSlashString().(tc.in)
35 requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Equal().(t, tc.want, result)
36 })
37 }
38 }
39
40 func Benchmark_AddTrailingSlashStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/Benchmark_AddTrailingSlashString().(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
41 cases := []struct {
42 name string
43 input string
44 }{
45 {name: "empty", input: ""},
46 {name: "slash-only", input: "/"},
47 {name: "short-no-slash", input: "abc"},
48 {name: "short-with-slash", input: "abc/"},
49 {name: "path-no-slash", input: "/api/v1/users"},
50 {name: "path-with-slash", input: "/api/v1/users/"},
51 }
52
53 for _, tc := range cases {
54 b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.name, func(b *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Bscip-go gomod github.com/golang/go/src go1.25.0 testing/B#) {
55 b.ReportAllocsscip-go gomod github.com/golang/go/src go1.25.0 testing/B#ReportAllocs().()
56 var res string
57 for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ {
58 res = AddTrailingSlashStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2`/AddTrailingSlashString().(tc.input)
59 }
60 _ = res
61 })
62 }
63 }