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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
package strcase
import "testing"
func TestLowerCaseFirstLetterOrAcronyms(t *testing.T) {
cases := []struct {
in string
want string
}{
{"", ""},
{"t", "t"},
{"Test Case", "test Case"},
{"test Case", "test Case"},
{"TEST CASE", "tEST CASE"},
{"tEST CASE", "tEST CASE"},
{"#EST CASE", "#EST CASE"},
{"APITest", "apiTest"},
{"AVATATest", "aVATATest"},
{"TestStuff", "testStuff"},
}
for _, c := range cases {
result := lowerCaseFirstLetterOrAcronyms(c.in)
if result != c.want {
t.Errorf("lowerCaseFirstLetterOrAcronyms(%q) == %q, want %q", c.in, result, c.want)
}
}
}
func TestTitleFirstWord(t *testing.T) {
cases := [][]string{
{"", ""},
{"t", "T"},
{"Test Case", "Test Case"},
{"test Case", "Test Case"},
{"test case", "Test case"},
{"TEST CASE", "TEST CASE"},
{"tEST CASE", "TEST CASE"},
{"#EST CASE", "#EST CASE"},
}
for _, i := range cases {
in := i[0]
out := i[1]
result := TitleFirstWord(in)
if result != out {
t.Error("'" + result + "' != '" + out + "'")
}
}
}
func Test_UntitleFirstWord(t *testing.T) {
cases := [][]string{
{"", ""},
{"T", "t"},
{"UUID", "UUID"},
{"UUI", "uUI"},
{"TEST CASE", "tEST CASE"},
}
for _, i := range cases {
in := i[0]
out := i[1]
result := UntitleFirstWord(in)
if result != out {
t.Error("'" + result + "' != '" + out + "'")
}
}
}
|