| 1 | package stringsscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 5 | stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/ "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 7 | |
| 8 | "github.com/gofiber/utils/v2/internal/unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | type benchCasescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase# struct { |
| 13 | namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name. string |
| 14 | inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input. string |
| 15 | lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower. string |
| 16 | upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper. string |
| 17 | } |
| 18 | |
| 19 | var testCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/testCases. = []benchCasescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#{ |
| 20 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "empty", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: ""}, |
| 21 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "numbers", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "1234567890", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "1234567890", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "1234567890"}, |
| 22 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "symbols", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "!@#$%^&*()", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "!@#$%^&*()", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "!@#$%^&*()"}, |
| 23 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "single-lower", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "a", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "A", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "a"}, |
| 24 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "single-upper", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "A", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "A", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "a"}, |
| 25 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "lowercase", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "abcdefghijklmnopqrstuvwxyz", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "abcdefghijklmnopqrstuvwxyz"}, |
| 26 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "uppercase", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "abcdefghijklmnopqrstuvwxyz"}, |
| 27 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "mixed-case", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "aBcDeFgHiJkLmNoPqRsTuVwXyZ", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "abcdefghijklmnopqrstuvwxyz"}, |
| 28 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "non-ascii", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "µßäöü", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "µßäöü", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "µßäöü"}, |
| 29 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "mixed-ascii-non-ascii", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "Goµ", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "GOµ", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "goµ"}, |
| 30 | } |
| 31 | |
| 32 | var benchmarkCoreCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchmarkCoreCases. = []benchCasescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#{ |
| 33 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "empty", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: ""}, |
| 34 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "http-get", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "get", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "GET", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "get"}, |
| 35 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "http-get-upper", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "GET", upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "GET", lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "get"}, |
| 36 | { |
| 37 | namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "header-content-type-mixed", |
| 38 | inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: "Content-Type: text/html; charset=utf-8", |
| 39 | upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: "CONTENT-TYPE: TEXT/HTML; CHARSET=UTF-8", |
| 40 | lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: "content-type: text/html; charset=utf-8", |
| 41 | }, |
| 42 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "large-lower", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", 64), upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("A", 64), lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", 64)}, |
| 43 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "large-upper", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("A", 64), upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("A", 64), lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("a", 64)}, |
| 44 | {namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#name.: "large-mixed", inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("aB", 32), upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("AB", 32), lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower.: stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.25.0 strings/Repeat().("ab", 32)}, |
| 45 | } |
| 46 | |
| 47 | func Test_ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_ToUpper().(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#) { |
| 48 | for _, tc := range testCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/testCases. { |
| 49 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#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#) { |
| 50 | 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.upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper., ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.)) |
| 51 | }) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func Test_ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_ToLower().(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#) { |
| 56 | for _, tc := range testCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/testCases. { |
| 57 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tc.namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#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#) { |
| 58 | 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.lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower., ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.)) |
| 59 | }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func Test_ASCII_EdgeCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_ASCII_EdgeCases().(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#) { |
| 64 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 65 | for idx := range 128 { |
| 66 | c := byte(idx) |
| 67 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("ASCII-char-%03d", idx), 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#) { |
| 68 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 69 | s := string(c) |
| 70 | 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, stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25.0 strings/ToUpper().(s), ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(s)) |
| 71 | 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, stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(s), ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(s)) |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func Test_ToLower_NoMutationscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_ToLower_NoMutation().(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#) { |
| 77 | in := "Content-Type" |
| 78 | out := ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(in) |
| 79 | 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, "content-type", out) |
| 80 | 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, "Content-Type", in) |
| 81 | } |
| 82 | |
| 83 | func Test_ToUpper_NoMutationscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_ToUpper_NoMutation().(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#) { |
| 84 | in := "content-type" |
| 85 | out := ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(in) |
| 86 | 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, "CONTENT-TYPE", out) |
| 87 | 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, "content-type", in) |
| 88 | } |
| 89 | |
| 90 | func TestUnsafeToLower_Mutatesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/TestUnsafeToLower_Mutates().(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#) { |
| 91 | buf := []byte("Content-Type") |
| 92 | s := unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(buf) |
| 93 | out := UnsafeToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToLower().(s) |
| 94 | 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, "content-type", out) |
| 95 | 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, "content-type", string(buf)) |
| 96 | } |
| 97 | |
| 98 | func TestUnsafeToUpper_Mutatesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/TestUnsafeToUpper_Mutates().(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#) { |
| 99 | buf := []byte("content-type") |
| 100 | s := unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(buf) |
| 101 | out := UnsafeToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToUpper().(s) |
| 102 | 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, "CONTENT-TYPE", out) |
| 103 | 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, "CONTENT-TYPE", string(buf)) |
| 104 | } |
| 105 | |
| 106 | func Benchmark_ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Benchmark_ToUpper().(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#) { |
| 107 | for _, tc := range benchmarkCoreCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchmarkCoreCases. { |
| 108 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#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#) { |
| 109 | b.ReportAllocsscip-go gomod github.com/golang/go/src go1.25.0 testing/B#ReportAllocs().() |
| 110 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.))) |
| 111 | var fiberRes, stdRes string |
| 112 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("fiber", 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#) { |
| 113 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 114 | fiberRes = ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 115 | } |
| 116 | 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().(b, tc.upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper., fiberRes) |
| 117 | }) |
| 118 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("fiber/unsafe", 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#) { |
| 119 | template := []byte(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 120 | work := make([]byte, len(template)) |
| 121 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 122 | copy(work, template) |
| 123 | fiberRes = UnsafeToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToUpper().(unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(work)) |
| 124 | } |
| 125 | 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().(b, tc.upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper., fiberRes) |
| 126 | }) |
| 127 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("default", 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#) { |
| 128 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 129 | stdRes = stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToUpperscip-go gomod github.com/golang/go/src go1.25.0 strings/ToUpper().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 130 | } |
| 131 | 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().(b, tc.upperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#upper., stdRes) |
| 132 | }) |
| 133 | }) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func Benchmark_ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Benchmark_ToLower().(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#) { |
| 138 | for _, tc := range benchmarkCoreCasesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchmarkCoreCases. { |
| 139 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().(tc.namescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#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#) { |
| 140 | b.ReportAllocsscip-go gomod github.com/golang/go/src go1.25.0 testing/B#ReportAllocs().() |
| 141 | b.SetBytesscip-go gomod github.com/golang/go/src go1.25.0 testing/B#SetBytes().(int64(len(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.))) |
| 142 | var fiberRes, stdRes string |
| 143 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("fiber", 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#) { |
| 144 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 145 | fiberRes = ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 146 | } |
| 147 | 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().(b, tc.lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower., fiberRes) |
| 148 | }) |
| 149 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("fiber/unsafe", 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#) { |
| 150 | template := []byte(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 151 | work := make([]byte, len(template)) |
| 152 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 153 | copy(work, template) |
| 154 | fiberRes = UnsafeToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToLower().(unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(work)) |
| 155 | } |
| 156 | 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().(b, tc.lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower., fiberRes) |
| 157 | }) |
| 158 | b.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/B#Run().("default", 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#) { |
| 159 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.25.0 testing/B#N.; i++ { |
| 160 | stdRes = stdstringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(tc.inputscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#input.) |
| 161 | } |
| 162 | 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().(b, tc.lowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/benchCase#lower., stdRes) |
| 163 | }) |
| 164 | }) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // Test_Case_FirstChangePositions plants the single case-changing byte at |
| 169 | // every position of every length up to 100, covering the caseconv scan's |
| 170 | // 32-byte block loop, the word loop behind it, the overlapping tail, and the |
| 171 | // identity path, against a byte-wise reference. |
| 172 | func Test_Case_FirstChangePositionsscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_Case_FirstChangePositions().(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#) { |
| 173 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 174 | refLower := func(s string) string { |
| 175 | b := []byte(s) |
| 176 | for i := range b { |
| 177 | if b[i] >= 'A' && b[i] <= 'Z' { |
| 178 | b[i] += 'a' - 'A' |
| 179 | } |
| 180 | } |
| 181 | return string(b) |
| 182 | } |
| 183 | refUpper := func(s string) string { |
| 184 | b := []byte(s) |
| 185 | for i := range b { |
| 186 | if b[i] >= 'a' && b[i] <= 'z' { |
| 187 | b[i] -= 'a' - 'A' |
| 188 | } |
| 189 | } |
| 190 | return string(b) |
| 191 | } |
| 192 | for n := 0; n <= 100; n++ { |
| 193 | base := make([]byte, n) |
| 194 | for i := range base { |
| 195 | base[i] = "40-\xe9/~:9"[i%8] // no letters at all, incl. >= 0x80 |
| 196 | } |
| 197 | // Identity inputs: both directions must return the input itself |
| 198 | // (the scans' no-match fast path), not an equal copy. |
| 199 | s := string(base) |
| 200 | lower, upper := ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(s), ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(s) |
| 201 | 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, s, lower, "identity lower len %d", n) |
| 202 | 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, s, upper, "identity upper len %d", n) |
| 203 | if n > 0 { |
| 204 | sb, lb, ub := unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeBytesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeBytes().(s), unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeBytesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeBytes().(lower), unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeBytesscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeBytes().(upper) |
| 205 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Samescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Same().(t, &sb[0], &lb[0], "identity lower must return the input, len %d", n) |
| 206 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Samescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Same().(t, &sb[0], &ub[0], "identity upper must return the input, len %d", n) |
| 207 | } |
| 208 | for at := 0; at < n; at++ { |
| 209 | b := append([]byte(nil), base...) |
| 210 | b[at] = 'Q' |
| 211 | s := string(b) |
| 212 | 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, refLower(s), ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(s), "lower len %d at %d", n, at) |
| 213 | 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, refUpper(s), ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(s), "upper len %d at %d", n, at) |
| 214 | b[at] = 'q' |
| 215 | s = string(b) |
| 216 | 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, refLower(s), ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(s), "lower len %d at %d", n, at) |
| 217 | 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, refUpper(s), ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(s), "upper len %d at %d", n, at) |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // Test_Case_PathCoverage exercises every dispatch path of the string case |
| 223 | // converters in-package: sub-word inputs, word-path inputs, identity |
| 224 | // returns, and the in-place variants across both length regimes. |
| 225 | func Test_Case_PathCoveragescip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/Test_Case_PathCoverage().(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#) { |
| 226 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 227 | |
| 228 | cases := []struct{ in, lower, upper string }{ |
| 229 | {"", "", ""}, |
| 230 | {"a", "a", "A"}, |
| 231 | {"AbC", "abc", "ABC"}, |
| 232 | {"\xe9!z", "\xe9!z", "\xe9!Z"}, |
| 233 | {"abcdefgh", "abcdefgh", "ABCDEFGH"}, |
| 234 | {"nochangehere-1234", "nochangehere-1234", "NOCHANGEHERE-1234"}, |
| 235 | {"aaaaaaaaaXbbbb", "aaaaaaaaaxbbbb", "AAAAAAAAAXBBBB"}, |
| 236 | {"aaaaaaaaaaaaY", "aaaaaaaaaaaay", "AAAAAAAAAAAAY"}, |
| 237 | } |
| 238 | for _, tc := range cases { |
| 239 | 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.lower, ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().(tc.in), "ToLower %q", tc.in) |
| 240 | 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.upper, ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().(tc.in), "ToUpper %q", tc.in) |
| 241 | |
| 242 | lowerBuf := []byte(tc.in) |
| 243 | 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.lower, UnsafeToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToLower().(unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(lowerBuf)), "UnsafeToLower %q", tc.in) |
| 244 | upperBuf := []byte(tc.in) |
| 245 | 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.upper, UnsafeToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/UnsafeToUpper().(unsafeconvscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/.UnsafeStringscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/internal/unsafeconv`/UnsafeString().(upperBuf)), "UnsafeToUpper %q", tc.in) |
| 246 | } |
| 247 | |
| 248 | // Unchanged inputs come back as-is (the fast identity paths). |
| 249 | 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, "short", ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().("short")) |
| 250 | 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, "SHORT", ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().("SHORT")) |
| 251 | 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, "already lower, one word plus", ToLowerscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToLower().("already lower, one word plus")) |
| 252 | 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, "ALREADY UPPER, ONE WORD PLUS", ToUpperscip-go gomod github.com/gofiber/utils/v2 . `github.com/gofiber/utils/v2/strings`/ToUpper().("ALREADY UPPER, ONE WORD PLUS")) |
| 253 | } |