Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions SHOULDERS.md

This file was deleted.

152 changes: 0 additions & 152 deletions acronyms.go

This file was deleted.

84 changes: 84 additions & 0 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package flect

import "testing"

// benchInputs exercises the key code paths: acronym fast-path, camelCase
// splitting, underscore-separated words, multi-segment paths, and plain words.
var benchInputs = []string{
"widget",
"widget_id",
"WidgetID",
"Widget_ID",
"HTMLParser",
"JSONResponse",
"admin/widget",
"bob dylan",
"Nice to see you!",
"ThisIsALongCamelCaseString",
"JWTName",
"foo_bar_baz",
}

func BenchmarkCamelize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Camelize(s)
}
}
}

func BenchmarkPascalize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Pascalize(s)
}
}
}

func BenchmarkDasherize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Dasherize(s)
}
}
}

func BenchmarkTitleize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Titleize(s)
}
}
}

func BenchmarkHumanize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Humanize(s)
}
}
}

func BenchmarkCapitalize(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
for _, s := range benchInputs {
Capitalize(s)
}
}
}

func BenchmarkOrdinalize(b *testing.B) {
b.ReportAllocs()
inputs := []string{"1", "2", "3", "11", "12", "13", "21", "42", "100", "101", "111", "1001"}
for n := 0; n < b.N; n++ {
for _, s := range inputs {
Ordinalize(s)
}
}
}
4 changes: 1 addition & 3 deletions camelize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package flect

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_Camelize(t *testing.T) {
Expand Down Expand Up @@ -36,7 +34,7 @@ func Test_Camelize(t *testing.T) {

for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r := newRequire(st)
r.Equal(tt.exp, Camelize(tt.act))
r.Equal(tt.exp, Camelize(tt.exp))
})
Expand Down
4 changes: 1 addition & 3 deletions capitalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package flect

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_Capitalize(t *testing.T) {
Expand All @@ -20,7 +18,7 @@ func Test_Capitalize(t *testing.T) {

for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r := newRequire(st)
r.Equal(tt.exp, Capitalize(tt.act))
r.Equal(tt.exp, Capitalize(tt.exp))
})
Expand Down
4 changes: 1 addition & 3 deletions dasherize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package flect

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_Dasherize(t *testing.T) {
Expand All @@ -21,7 +19,7 @@ func Test_Dasherize(t *testing.T) {

for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r := newRequire(st)
r.Equal(tt.exp, Dasherize(tt.act))
r.Equal(tt.exp, Dasherize(tt.exp))
})
Expand Down
Loading
Loading