Skip to content

Commit 078472c

Browse files
committed
internal/cligen: cover the empty/underscore/$ guard branches
Add table cases for the special-cased early returns in camelName/snakeName and the '$'-skip branch in splitASCII, bringing the pure name/casing logic to full statement coverage. Co-authored-by: Isaac
1 parent b47043d commit 078472c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

internal/cligen/names_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func TestNameCasings(t *testing.T) {
1616
{"IpAccessLists", "ip-access-lists", "ip_access_lists", "IpAccessLists", "ipAccessLists", "IP_ACCESS_LISTS", "Ip Access Lists"},
1717
{"IamV2", "iam-v2", "iam_v2", "IamV2", "iamV2", "IAM_V2", "Iam V2"},
1818
{"create_run", "create-run", "create_run", "CreateRun", "createRun", "CREATE_RUN", "Create Run"},
19+
// Empty and "_" hit the special-cased early returns in camelName/snakeName;
20+
// note kebab/title/pascal do not special-case them, so they differ.
21+
{"", "", "", "", "", "", ""},
22+
{"_", "", "_", "", "_", "_", ""},
1923
}
2024
for _, c := range cases {
2125
if got := kebabName(c.name); got != c.kebab {

internal/cligen/split_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func TestSplitASCII(t *testing.T) {
2121
{"_", nil},
2222
{"__", nil},
2323

24+
// '$' is dropped entirely, joining its neighbors.
25+
{"foo$bar", []string{"foobar"}},
26+
{"$foo", []string{"foo"}},
27+
2428
// Single words, any casing, lowercased output.
2529
{"a", []string{"a"}},
2630
{"A", []string{"a"}},

0 commit comments

Comments
 (0)