Add test for ToScreamingDelimitedWithIgnore
This commit is contained in:
parent
e7b55ac809
commit
cb1a286566
6
snake.go
6
snake.go
@ -94,7 +94,11 @@ func ToScreamingDelimited(s string, delimiter uint8, ignore uint8, screaming boo
|
||||
}
|
||||
} else if v == ' ' || v == '_' || v == '-' {
|
||||
// replace spaces/underscores with delimiters
|
||||
n += string(delimiter)
|
||||
if uint8(v) == ignore {
|
||||
n += string(v)
|
||||
} else {
|
||||
n += string(delimiter)
|
||||
}
|
||||
} else {
|
||||
n = n + string(v)
|
||||
}
|
||||
|
@ -179,3 +179,19 @@ func TestToScreamingDelimited(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestToScreamingDelimitedWithIgnore(t *testing.T) {
|
||||
cases := [][]string{
|
||||
{"AnyKind of_string", "ANY.KIND OF.STRING", ".", " "},
|
||||
}
|
||||
for _, i := range cases {
|
||||
in := i[0]
|
||||
out := i[1]
|
||||
delimiter := uint8(i[2][0])
|
||||
ignore := uint8(i[3][0])
|
||||
result := ToScreamingDelimited(in, delimiter, ignore, true)
|
||||
if result != out {
|
||||
t.Error("'" + result + "' != '" + out + "'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user