Skip to content

Commit

Permalink
Merge pull request #63 from gobuffalo/preparing-v1
Browse files Browse the repository at this point in the history
removed deprecated strings.Title(), updated test cases and benchmarks
  • Loading branch information
sio4 authored Jan 9, 2023
2 parents 17261fe + 7d1eabd commit f4baef4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
10 changes: 3 additions & 7 deletions humanize.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ func (i Ident) Humanize() Ident {
return New("")
}

var parts []string
for index, part := range i.Parts {
if index == 0 {
part = strings.Title(i.Parts[0])
}

parts = xappend(parts, part)
parts := xappend([]string{}, Titleize(i.Parts[0]))
if len(i.Parts) > 1 {
parts = xappend(parts, i.Parts[1:]...)
}

return New(strings.Join(parts, " "))
Expand Down
3 changes: 3 additions & 0 deletions humanize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
func Test_Humanize(t *testing.T) {
table := []tt{
{"", ""},
{"id", "ID"},
{"url", "URL"},
{"IBM", "IBM"},
{"CAUTION! CAPs are CAPs!", "CAUTION! CAPs are CAPs!"},
{"employee_mobile_number", "Employee mobile number"},
{"employee_salary", "Employee salary"},
{"employee_id", "Employee ID"},
Expand Down
11 changes: 11 additions & 0 deletions pluralize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ func Test_PluralizeWithSize(t *testing.T) {
})
}
}

func BenchmarkPluralize(b *testing.B) {
for n := 0; n < b.N; n++ {
for _, tt := range singlePluralAssertions {
if tt.doPluralizeTest {
Pluralize(tt.singular)
Pluralize(tt.plural)
}
}
}
}
11 changes: 11 additions & 0 deletions singularize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ func Test_SingularizeWithSize(t *testing.T) {
})
}
}

func BenchmarkSingularize(b *testing.B) {
for n := 0; n < b.N; n++ {
for _, tt := range singlePluralAssertions {
if tt.doSingularizeTest {
Singularize(tt.singular)
Singularize(tt.plural)
}
}
}
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package flect

//Version holds Flect version number
const Version = "v0.1.6"
const Version = "v1.0.0"

0 comments on commit f4baef4

Please sign in to comment.