forked from iancoleman/strcase
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request iancoleman#32 from penhauer/master
ignore multiple chars in snake_case
- Loading branch information
Showing
2 changed files
with
16 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,14 +92,16 @@ func toSnakeWithIgnore(tb testing.TB) { | |
{"JSONData", "json_data"}, | ||
{"AwesomeActivity.UserID", "awesome_activity.user_id", "."}, | ||
{"AwesomeActivity.User.Id", "awesome_activity.user.id", "."}, | ||
{"[email protected]", "[email protected]", "@"}, | ||
{"[email protected]", "[email protected]", ".@"}, | ||
{"lets-ignore all.of dots-and-dashes", "lets-ignore_all.of_dots-and-dashes", ".-"}, | ||
} | ||
for _, i := range cases { | ||
in := i[0] | ||
out := i[1] | ||
var ignore uint8 | ||
var ignore string | ||
ignore = "" | ||
if len(i) == 3 { | ||
ignore = i[2][0] | ||
ignore = i[2] | ||
} | ||
result := ToSnakeWithIgnore(in, ignore) | ||
if result != out { | ||
|
@@ -222,7 +224,7 @@ func toScreamingDelimited(tb testing.TB) { | |
for _, i := range cases { | ||
in := i[0] | ||
out := i[1] | ||
result := ToScreamingDelimited(in, '.', 0, true) | ||
result := ToScreamingDelimited(in, '.', "", true) | ||
if result != out { | ||
tb.Errorf("%q (%q != %q)", in, result, out) | ||
} | ||
|
@@ -244,7 +246,7 @@ func toScreamingDelimitedWithIgnore(tb testing.TB) { | |
out := i[1] | ||
delimiter := i[2][0] | ||
ignore := i[3][0] | ||
result := ToScreamingDelimited(in, delimiter, ignore, true) | ||
result := ToScreamingDelimited(in, delimiter, string(ignore), true) | ||
if result != out { | ||
istr := "" | ||
if len(i) == 4 { | ||
|