...
1 package name
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func Test_Tableize(t *testing.T) {
10 table := []tt{
11 {"", ""},
12 {"bob dylan", "bob_dylans"},
13 {"Nice to see you!", "nice_to_see_you"},
14 {"*hello*", "hellos"},
15 {"i've read a book! have you?", "ive_read_a_book_have_you"},
16 {"This is `code` ok", "this_is_code_oks"},
17 {"foo_bar", "foo_bars"},
18 {"admin/widget", "admin_widgets"},
19 {"widget", "widgets"},
20 {"widgets", "widgets"},
21 {"status", "statuses"},
22 {"Statuses", "statuses"},
23 {"statuses", "statuses"},
24 {"People", "people"},
25 {"people", "people"},
26 {"BigPerson", "big_people"},
27 {"Wild Ox", "wild_oxen"},
28 }
29
30 for _, tt := range table {
31 t.Run(tt.act, func(st *testing.T) {
32 r := require.New(st)
33 r.Equal(tt.exp, Tableize(tt.act))
34 r.Equal(tt.exp, Tableize(tt.exp))
35 })
36 }
37 }
38
View as plain text