| 36 | } |
| 37 | |
| 38 | func TestCamelCase(t *testing.T) { |
| 39 | cases := map[string]struct { |
| 40 | str string |
| 41 | firstUpper bool |
| 42 | useAcronym bool |
| 43 | expected string |
| 44 | }{ |
| 45 | "all lower": {"aaa", false, true, "aaa"}, |
| 46 | "all lower first upper": {"aaa", true, true, "Aaa"}, |
| 47 | "start upper": {"Aaa", false, true, "aaa"}, |
| 48 | "mid upper": {"a_aa", false, true, "aAa"}, |
| 49 | "end upper": {"aa_a", false, true, "aaA"}, |
| 50 | "sequential uppers": {"aa_aaaa", false, true, "aaAaaa"}, |
| 51 | "end sequential uppers": {"aa_aa", false, true, "aaAa"}, |
| 52 | "multiple_uppers": {"aa_aaa_aaa", false, true, "aaAaaAaa"}, |
| 53 | "underscores": {"aa_aaa_aaa", false, true, "aaAaaAaa"}, |
| 54 | "acronym": {"aa_id", false, true, "aaID"}, |
| 55 | "lower camel case": {"aa_id", false, false, "aaId"}, |
| 56 | "upper camel case": {"aaID", false, true, "aaID"}, |
| 57 | "lower camel case with acronym": {"aaId", false, true, "aaID"}, |
| 58 | |
| 59 | "disable acronym": {"aa_id", false, false, "aaId"}, |
| 60 | "disable acronym first upper": {"aaID", true, false, "AaId"}, |
| 61 | "disable acronym upper case acronym": {"aa_ID", false, false, "aaId"}, |
| 62 | "disable acronym upper camel case": {"aaID", false, false, "aaId"}, |
| 63 | "disable acronym lower camel case": {"aaId", false, false, "aaId"}, |
| 64 | } |
| 65 | for k, tc := range cases { |
| 66 | t.Run(k, func(t *testing.T) { |
| 67 | actual := CamelCase(tc.str, tc.firstUpper, tc.useAcronym) |
| 68 | if actual != tc.expected { |
| 69 | t.Errorf("got %q, expected %q", actual, tc.expected) |
| 70 | } |
| 71 | }) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func TestKebabCase(t *testing.T) { |
| 76 | cases := map[string]struct { |