feat: query_parser + stringcase.

This commit is contained in:
Bobo
2025-06-23 23:26:59 +08:00
parent de36ab695d
commit 55c80024c2
22 changed files with 1362 additions and 148 deletions

View File

@@ -0,0 +1,49 @@
package stringcase
import "testing"
func TestKebabCase(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"HelloWorld", "hello-world"},
{"helloWorld", "hello-world"},
{"Hello World", "hello-world"},
{"hello world!", "hello-world"},
{"Numbers123Test", "numbers-123-test"},
{"", ""},
{"_", ""},
{"__Hello__World__", "hello-world"},
}
for _, test := range tests {
result := KebabCase(test.input)
if result != test.expected {
t.Errorf("KebabCase(%q) = %q; expected %q", test.input, result, test.expected)
}
}
}
func TestUpperKebabCase(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"HelloWorld", "HELLO-WORLD"},
{"helloWorld", "HELLO-WORLD"},
{"Hello World", "HELLO-WORLD"},
{"hello world!", "HELLO-WORLD"},
{"Numbers123Test", "NUMBERS-123-TEST"},
{"", ""},
{"_", ""},
{"__Hello__World__", "HELLO-WORLD"},
}
for _, test := range tests {
result := UpperKebabCase(test.input)
if result != test.expected {
t.Errorf("UpperKebabCase(%q) = %q; expected %q", test.input, result, test.expected)
}
}
}