forked from gobuffalo/flect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
underscore_test.go
48 lines (40 loc) · 864 Bytes
/
underscore_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package flect
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Underscore(t *testing.T) {
baseAcronyms["TLC"] = true
table := []tt{
{"", ""},
{"bob dylan", "bob_dylan"},
{"Nice to see you!", "nice_to_see_you"},
{"*hello*", "hello"},
{"i've read a book! have you?", "ive_read_a_book_have_you"},
{"This is `code` ok", "this_is_code_ok"},
{"TLCForm", "tlc_form"},
}
for _, tt := range table {
t.Run(tt.act, func(st *testing.T) {
r := require.New(st)
r.Equal(tt.exp, Underscore(tt.act))
r.Equal(tt.exp, Underscore(tt.exp))
})
}
}
func Benchmark_Underscore(b *testing.B) {
table := []string{
"",
"bob dylan",
"Nice to see you!",
"*hello*",
"i've read a book! have you?",
"This is `code` ok",
"TLCForm",
}
for n := 0; n < b.N; n++ {
for i := range table {
Underscore(table[i])
}
}
}