diff --git a/Makefile b/Makefile index 462f8b4..a4d59e8 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ .PHONY: benchmark docs lint test docs: - which godoc2ghmd || ( go get github.com/DevotedHealth/godoc2ghmd && go mod tidy ) + which godoc2ghmd || go install github.com/DevotedHealth/godoc2ghmd godoc2ghmd -template .readme.tmpl github.com/ettle/strcase > README.md test: go test -cover ./... lint: - which golangci-lint || ( go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0 && go mod tidy ) + which golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0 golangci-lint run golangci-lint run benchmark/*.go diff --git a/README.md b/README.md index ee165e3..46f30b9 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Example usage strcase.ToKebab("helloWorld") // hello-world strcase.ToKEBAB("helloWorld") // HELLO-WORLD + strcase.ToHeader("helloWorld") // Hello-World strcase.ToPascal("hello-world") // HelloWorld strcase.ToCamel("hello-world") // helloWorld @@ -32,7 +33,7 @@ Example usage strcase.ToSnake("FOOBar") // foo_bar // Support Go initialisms - strcase.ToGoCamel("http_response") // HTTPResponse + strcase.ToGoPascal("http_response") // HTTPResponse // Specify case and delimiter strcase.ToCase("HelloWorld", strcase.UpperCase, '.') // HELLO.WORLD @@ -76,7 +77,7 @@ the initialisms if you wish to add additional ones, such as "SSL" or "CMS" or domain specific ones to your industry. - ToGoCamel("http_response") // HTTPResponse + ToGoPascal("http_response") // HTTPResponse ToGoSnake("http_response") // HTTP_response ### Test coverage @@ -96,35 +97,35 @@ Hopefully I was fair to each library and happy to rerun benchmarks differently or reword my commentary based on suggestions or updates. - // This package - // Go intialisms and custom casers are slower - BenchmarkToTitle-4 992491 1559 ns/op 32 B/op 1 allocs/op - BenchmarkToSnake-4 1000000 1475 ns/op 32 B/op 1 allocs/op - BenchmarkToSNAKE-4 1000000 1609 ns/op 32 B/op 1 allocs/op - BenchmarkToGoSnake-4 275010 3697 ns/op 44 B/op 4 allocs/op - BenchmarkToCustomCaser-4 342704 4191 ns/op 56 B/op 4 allocs/op + // This package - faster then almost all libraries + // Initialisms are more complicated and slightly slower, but still faster then other libraries that do less + BenchmarkToTitle-4 7821166 221 ns/op 32 B/op 1 allocs/op + BenchmarkToSnake-4 9378589 202 ns/op 32 B/op 1 allocs/op + BenchmarkToSNAKE-4 6174453 223 ns/op 32 B/op 1 allocs/op + BenchmarkToGoSnake-4 3114266 434 ns/op 44 B/op 4 allocs/op + BenchmarkToCustomCaser-4 2973855 448 ns/op 56 B/op 4 allocs/op // Segment has very fast snake case and camel case libraries // No features or customization, but very very fast - BenchmarkSegment-4 1303809 938 ns/op 16 B/op 1 allocs/op + BenchmarkSegment-4 24003495 64.9 ns/op 16 B/op 1 allocs/op // Stdlib strings.Title for comparison, even though it only splits on spaces - BenchmarkToTitleStrings-4 1213467 1164 ns/op 16 B/op 1 allocs/op + BenchmarkToTitleStrings-4 11259376 161 ns/op 16 B/op 1 allocs/op // Other libraries or code snippets // - Most are slower, by up to an order of magnitude // - None support initialisms or customization // - Some generate only camelCase or snake_case // - Many lack unicode support - BenchmarkToSnakeStoewer-4 973200 2075 ns/op 64 B/op 2 allocs/op + BenchmarkToSnakeStoewer-4 7103268 297 ns/op 64 B/op 2 allocs/op // Copying small rune arrays is slow - BenchmarkToSnakeSiongui-4 264315 4229 ns/op 48 B/op 10 allocs/op - BenchmarkGoValidator-4 206811 5152 ns/op 184 B/op 9 allocs/op + BenchmarkToSnakeSiongui-4 3710768 413 ns/op 48 B/op 10 allocs/op + BenchmarkGoValidator-4 2416479 1049 ns/op 184 B/op 9 allocs/op // String alloction is slow - BenchmarkToSnakeFatih-4 82675 12280 ns/op 392 B/op 26 allocs/op - BenchmarkToSnakeIanColeman-4 83276 13903 ns/op 145 B/op 13 allocs/op + BenchmarkToSnakeFatih-4 1000000 2407 ns/op 624 B/op 26 allocs/op + BenchmarkToSnakeIanColeman-4 1005766 1426 ns/op 160 B/op 13 allocs/op // Regexp is slow - BenchmarkToSnakeGolangPrograms-4 74448 18586 ns/op 176 B/op 11 allocs/op + BenchmarkToSnakeGolangPrograms-4 614689 2237 ns/op 225 B/op 11 allocs/op // These results aren't a surprise - my initial version of this library was // painfully slow. I think most of us, without spending some time with @@ -168,6 +169,7 @@ custom casers to mimic the behavior of the other package. * [func ToGoKebab(s string) string](#ToGoKebab) * [func ToGoPascal(s string) string](#ToGoPascal) * [func ToGoSnake(s string) string](#ToGoSnake) +* [func ToHeader(s string) string](#ToHeader) * [func ToKEBAB(s string) string](#ToKEBAB) * [func ToKebab(s string) string](#ToKebab) * [func ToPascal(s string) string](#ToPascal) @@ -177,6 +179,7 @@ custom casers to mimic the behavior of the other package. * [func NewCaser(goInitialisms bool, initialismOverrides map[string]bool, splitFn SplitFn) *Caser](#NewCaser) * [func (c *Caser) ToCamel(s string) string](#Caser.ToCamel) * [func (c *Caser) ToCase(s string, wordCase WordCase, delimiter rune) string](#Caser.ToCase) + * [func (c *Caser) ToHeader(s string) string](#Caser.ToHeader) * [func (c *Caser) ToKEBAB(s string) string](#Caser.ToKEBAB) * [func (c *Caser) ToKebab(s string) string](#Caser.ToKebab) * [func (c *Caser) ToPascal(s string) string](#Caser.ToPascal) @@ -201,7 +204,7 @@ Also known as lowerCamelCase or mixedCase. -## func [ToCase](./strcase.go#L70) +## func [ToCase](./strcase.go#L77) ``` go func ToCase(s string, wordCase WordCase, delimiter rune) string ``` @@ -209,18 +212,20 @@ ToCase returns words in given case and delimiter. -## func [ToGoCamel](./strcase.go#L65) +## func [ToGoCamel](./strcase.go#L67) ``` go func ToGoCamel(s string) string ``` ToGoCamel returns words in camelCase (capitalized words concatenated together, with first word lower case). Also known as lowerCamelCase or mixedCase. -Respects Go's common initialisms (e.g. httpResponse -> HTTPResponse). +Respects Go's common initialisms, but first word remains lowercased which is +important for code generator use cases (e.g. toJson -> toJSON, httpResponse +-> httpResponse). -## func [ToGoCase](./strcase.go#L77) +## func [ToGoCase](./strcase.go#L84) ``` go func ToGoCase(s string, wordCase WordCase, delimiter rune) string ``` @@ -262,6 +267,14 @@ Respects Go's common initialisms (e.g. http_response -> HTTP_response). +## func [ToHeader](./strcase.go#L72) +``` go +func ToHeader(s string) string +``` +ToHeader returns words in Header-Case (capitalized words with dashes). + + + ## func [ToKEBAB](./strcase.go#L37) ``` go func ToKEBAB(s string) string @@ -357,7 +370,7 @@ Also known as lowerCamelCase or mixedCase. -### func (\*Caser) [ToCase](./caser.go#L85) +### func (\*Caser) [ToCase](./caser.go#L90) ``` go func (c *Caser) ToCase(s string, wordCase WordCase, delimiter rune) string ``` @@ -366,6 +379,15 @@ ToCase returns words with a given case and delimiter. +### func (\*Caser) [ToHeader](./caser.go#L85) +``` go +func (c *Caser) ToHeader(s string) string +``` +ToHeader returns words in Header-Case (capitalized words with dashes). + + + + ### func (\*Caser) [ToKEBAB](./caser.go#L68) ``` go func (c *Caser) ToKEBAB(s string) string @@ -469,7 +491,6 @@ NewSplitFn returns a SplitFn based on the options provided. NewSplitFn covers the majority of common options that other strcase libraries provide and should allow you to simply create a custom caser. For more complicated use cases, feel free to write your own SplitFn -nolint:gocyclo @@ -524,6 +545,9 @@ const ( // TitleCase - Only first letter upper cased (Example) TitleCase // CamelCase - TitleCase except lower case first word (exampleText) + // Notably, even if the first word is an initialism, it will be lower + // cased. This is important for code generators where capital letters + // mean exported functions. i.e. jsonString(), not JSONString() CamelCase ) ``` diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go index 910743f..1e2e3e3 100644 --- a/benchmark/benchmark_test.go +++ b/benchmark/benchmark_test.go @@ -64,6 +64,16 @@ func BenchmarkToSNAKE(b *testing.B) { b.Fatalf("Expected %s, got %s", expected, s) } } +func BenchmarkToHeader(b *testing.B) { + var s string + for n := 0; n < b.N; n++ { + s = strcase.ToHeader(testCamel) + } + expected := testHeader + if expected != s { + b.Fatalf("Expected %s, got %s", expected, s) + } +} func BenchmarkToGoSnake(b *testing.B) { var s string for n := 0; n < b.N; n++ { diff --git a/caser.go b/caser.go index 891a671..ffe32a1 100644 --- a/caser.go +++ b/caser.go @@ -81,6 +81,11 @@ func (c *Caser) ToCamel(s string) string { return convert(s, c.splitFn, '\x00', CamelCase, c.initialisms) } +// ToHeader returns words in Header-Case (capitalized words with dashes). +func (c *Caser) ToHeader(s string) string { + return convert(s, c.splitFn, '-', TitleCase, c.initialisms) +} + // ToCase returns words with a given case and delimiter. func (c *Caser) ToCase(s string, wordCase WordCase, delimiter rune) string { return convert(s, c.splitFn, delimiter, wordCase, c.initialisms) diff --git a/caser_test.go b/caser_test.go index a6315a2..abd8f21 100644 --- a/caser_test.go +++ b/caser_test.go @@ -18,6 +18,7 @@ func TestCaserAll(t *testing.T) { KEBAB string pascal string camel string + header string title string } for _, test := range []data{ @@ -29,6 +30,7 @@ func TestCaserAll(t *testing.T) { KEBAB: "HELLO-WORLD!", pascal: "HelloWorld!", camel: "helloWorld!", + header: "Hello-World!", title: "Hello World!", }, } { @@ -41,6 +43,7 @@ func TestCaserAll(t *testing.T) { KEBAB: c.ToKEBAB(test.input), pascal: c.ToPascal(test.input), camel: c.ToCamel(test.input), + header: c.ToHeader(test.input), title: c.ToCase(test.input, TitleCase, ' '), } assert.Equal(t, test, output) diff --git a/doc.go b/doc.go index b898a4e..664dccf 100644 --- a/doc.go +++ b/doc.go @@ -11,6 +11,7 @@ Example usage strcase.ToKebab("helloWorld") // hello-world strcase.ToKEBAB("helloWorld") // HELLO-WORLD + strcase.ToHeader("helloWorld") // Hello-World strcase.ToPascal("hello-world") // HelloWorld strcase.ToCamel("hello-world") // helloWorld diff --git a/strcase.go b/strcase.go index 46b4f7a..8211d3b 100644 --- a/strcase.go +++ b/strcase.go @@ -68,6 +68,11 @@ func ToGoCamel(s string) string { return convertWithGoInitialisms(s, 0, CamelCase) } +// ToHeader returns words in Header-Case (capitalized words with dashes). +func ToHeader(s string) string { + return convertWithoutInitialisms(s, '-', TitleCase) +} + // ToCase returns words in given case and delimiter. func ToCase(s string, wordCase WordCase, delimiter rune) string { return convertWithoutInitialisms(s, delimiter, wordCase) diff --git a/strcase_test.go b/strcase_test.go index b199c9d..aa4a8d2 100644 --- a/strcase_test.go +++ b/strcase_test.go @@ -39,6 +39,7 @@ func TestAll(t *testing.T) { goPascal string camel string goCamel string + header string // Test ToCase function title string goTitle string @@ -56,6 +57,7 @@ func TestAll(t *testing.T) { goPascal: "HelloWorld!", camel: "helloWorld!", goCamel: "helloWorld!", + header: "Hello-World!", title: "Hello World!", goTitle: "Hello World!", }, @@ -71,6 +73,7 @@ func TestAll(t *testing.T) { goPascal: "", camel: "", goCamel: "", + header: "", title: "", goTitle: "", }, @@ -86,6 +89,7 @@ func TestAll(t *testing.T) { goPascal: "", camel: "", goCamel: "", + header: "", title: "", goTitle: "", }, @@ -101,6 +105,7 @@ func TestAll(t *testing.T) { goPascal: "A", camel: "a", goCamel: "a", + header: "A", title: "A", goTitle: "A", }, @@ -116,6 +121,7 @@ func TestAll(t *testing.T) { goPascal: "A", camel: "a", goCamel: "a", + header: "A", title: "A", goTitle: "A", }, @@ -131,6 +137,7 @@ func TestAll(t *testing.T) { goPascal: "Foo", camel: "foo", goCamel: "foo", + header: "Foo", title: "Foo", goTitle: "Foo", }, @@ -146,6 +153,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCase", camel: "snakeCase", goCamel: "snakeCase", + header: "Snake-Case", title: "Snake Case", goTitle: "Snake Case", }, @@ -161,6 +169,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCase", camel: "snakeCase", goCamel: "snakeCase", + header: "Snake-Case", title: "Snake Case", goTitle: "Snake Case", }, @@ -176,6 +185,7 @@ func TestAll(t *testing.T) { goPascal: "KebabCase", camel: "kebabCase", goCamel: "kebabCase", + header: "Kebab-Case", title: "Kebab Case", goTitle: "Kebab Case", }, @@ -191,6 +201,7 @@ func TestAll(t *testing.T) { goPascal: "PascalCase", camel: "pascalCase", goCamel: "pascalCase", + header: "Pascal-Case", title: "Pascal Case", goTitle: "Pascal Case", }, @@ -206,6 +217,7 @@ func TestAll(t *testing.T) { goPascal: "CamelCase", camel: "camelCase", goCamel: "camelCase", + header: "Camel-Case", title: "Camel Case", goTitle: "Camel Case", }, @@ -221,6 +233,7 @@ func TestAll(t *testing.T) { goPascal: "TitleCase", camel: "titleCase", goCamel: "titleCase", + header: "Title-Case", title: "Title Case", goTitle: "Title Case", }, @@ -236,6 +249,7 @@ func TestAll(t *testing.T) { goPascal: "PointCase", camel: "pointCase", goCamel: "pointCase", + header: "Point-Case", title: "Point Case", goTitle: "Point Case", }, @@ -251,6 +265,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCaseWithMoreWords", camel: "snakeCaseWithMoreWords", goCamel: "snakeCaseWithMoreWords", + header: "Snake-Case-With-More-Words", title: "Snake Case With More Words", goTitle: "Snake Case With More Words", }, @@ -266,6 +281,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCaseWithMoreWords", camel: "snakeCaseWithMoreWords", goCamel: "snakeCaseWithMoreWords", + header: "Snake-Case-With-More-Words", title: "Snake Case With More Words", goTitle: "Snake Case With More Words", }, @@ -281,6 +297,7 @@ func TestAll(t *testing.T) { goPascal: "KebabCaseWithMoreWords", camel: "kebabCaseWithMoreWords", goCamel: "kebabCaseWithMoreWords", + header: "Kebab-Case-With-More-Words", title: "Kebab Case With More Words", goTitle: "Kebab Case With More Words", }, @@ -296,6 +313,7 @@ func TestAll(t *testing.T) { goPascal: "PascalCaseWithMoreWords", camel: "pascalCaseWithMoreWords", goCamel: "pascalCaseWithMoreWords", + header: "Pascal-Case-With-More-Words", title: "Pascal Case With More Words", goTitle: "Pascal Case With More Words", }, @@ -311,6 +329,7 @@ func TestAll(t *testing.T) { goPascal: "CamelCaseWithMoreWords", camel: "camelCaseWithMoreWords", goCamel: "camelCaseWithMoreWords", + header: "Camel-Case-With-More-Words", title: "Camel Case With More Words", goTitle: "Camel Case With More Words", }, @@ -326,6 +345,7 @@ func TestAll(t *testing.T) { goPascal: "TitleCaseWithMoreWords", camel: "titleCaseWithMoreWords", goCamel: "titleCaseWithMoreWords", + header: "Title-Case-With-More-Words", title: "Title Case With More Words", goTitle: "Title Case With More Words", }, @@ -341,6 +361,7 @@ func TestAll(t *testing.T) { goPascal: "PointCaseWithMoreWords", camel: "pointCaseWithMoreWords", goCamel: "pointCaseWithMoreWords", + header: "Point-Case-With-More-Words", title: "Point Case With More Words", goTitle: "Point Case With More Words", }, @@ -356,6 +377,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCaseWithMultipleDelimiters", camel: "snakeCaseWithMultipleDelimiters", goCamel: "snakeCaseWithMultipleDelimiters", + header: "Snake-Case-With-Multiple-Delimiters", title: "Snake Case With Multiple Delimiters", goTitle: "Snake Case With Multiple Delimiters", }, @@ -371,6 +393,7 @@ func TestAll(t *testing.T) { goPascal: "SnakeCaseWithMultipleDelimiters", camel: "snakeCaseWithMultipleDelimiters", goCamel: "snakeCaseWithMultipleDelimiters", + header: "Snake-Case-With-Multiple-Delimiters", title: "Snake Case With Multiple Delimiters", goTitle: "Snake Case With Multiple Delimiters", }, @@ -386,6 +409,7 @@ func TestAll(t *testing.T) { goPascal: "KebabCaseWithMultipleDelimiters", camel: "kebabCaseWithMultipleDelimiters", goCamel: "kebabCaseWithMultipleDelimiters", + header: "Kebab-Case-With-Multiple-Delimiters", title: "Kebab Case With Multiple Delimiters", goTitle: "Kebab Case With Multiple Delimiters", }, @@ -401,6 +425,7 @@ func TestAll(t *testing.T) { goPascal: "TitleCaseWithMultipleDelimiters", camel: "titleCaseWithMultipleDelimiters", goCamel: "titleCaseWithMultipleDelimiters", + header: "Title-Case-With-Multiple-Delimiters", title: "Title Case With Multiple Delimiters", goTitle: "Title Case With Multiple Delimiters", }, @@ -416,6 +441,7 @@ func TestAll(t *testing.T) { goPascal: "PointCaseWithMultipleDelimiters", camel: "pointCaseWithMultipleDelimiters", goCamel: "pointCaseWithMultipleDelimiters", + header: "Point-Case-With-Multiple-Delimiters", title: "Point Case With Multiple Delimiters", goTitle: "Point Case With Multiple Delimiters", }, @@ -431,6 +457,7 @@ func TestAll(t *testing.T) { goPascal: "LeadingSpace", camel: "leadingSpace", goCamel: "leadingSpace", + header: "Leading-Space", title: "Leading Space", goTitle: "Leading Space", }, @@ -446,6 +473,7 @@ func TestAll(t *testing.T) { goPascal: "LeadingSpaces", camel: "leadingSpaces", goCamel: "leadingSpaces", + header: "Leading-Spaces", title: "Leading Spaces", goTitle: "Leading Spaces", }, @@ -461,6 +489,7 @@ func TestAll(t *testing.T) { goPascal: "LeadingWhitespaces", camel: "leadingWhitespaces", goCamel: "leadingWhitespaces", + header: "Leading-Whitespaces", title: "Leading Whitespaces", goTitle: "Leading Whitespaces", }, @@ -476,6 +505,7 @@ func TestAll(t *testing.T) { goPascal: "TrailingSpace", camel: "trailingSpace", goCamel: "trailingSpace", + header: "Trailing-Space", title: "Trailing Space", goTitle: "Trailing Space", }, @@ -491,6 +521,7 @@ func TestAll(t *testing.T) { goPascal: "TrailingSpaces", camel: "trailingSpaces", goCamel: "trailingSpaces", + header: "Trailing-Spaces", title: "Trailing Spaces", goTitle: "Trailing Spaces", }, @@ -506,6 +537,7 @@ func TestAll(t *testing.T) { goPascal: "TrailingWhitespaces", camel: "trailingWhitespaces", goCamel: "trailingWhitespaces", + header: "Trailing-Whitespaces", title: "Trailing Whitespaces", goTitle: "Trailing Whitespaces", }, @@ -521,6 +553,7 @@ func TestAll(t *testing.T) { goPascal: "OnBothSides", camel: "onBothSides", goCamel: "onBothSides", + header: "On-Both-Sides", title: "On Both Sides", goTitle: "On Both Sides", }, @@ -536,6 +569,7 @@ func TestAll(t *testing.T) { goPascal: "ManyOnBothSides", camel: "manyOnBothSides", goCamel: "manyOnBothSides", + header: "Many-On-Both-Sides", title: "Many On Both Sides", goTitle: "Many On Both Sides", }, @@ -551,6 +585,7 @@ func TestAll(t *testing.T) { goPascal: "WhitespacesOnBothSides", camel: "whitespacesOnBothSides", goCamel: "whitespacesOnBothSides", + header: "Whitespaces-On-Both-Sides", title: "Whitespaces On Both Sides", goTitle: "Whitespaces On Both Sides", }, @@ -566,6 +601,7 @@ func TestAll(t *testing.T) { goPascal: "ExtraSpacesInThisTestCaseOfMixedCases", camel: "extraSpacesInThisTestCaseOfMixedCases", goCamel: "extraSpacesInThisTestCaseOfMixedCases", + header: "Extra-Spaces-In-This-Test-Case-Of-Mixed-Cases", title: "Extra Spaces In This Test Case Of Mixed Cases", goTitle: "Extra Spaces In This Test Case Of Mixed Cases", }, @@ -581,6 +617,7 @@ func TestAll(t *testing.T) { goPascal: "CaseBreak", camel: "caseBreak", goCamel: "caseBreak", + header: "Case-Break", title: "Case Break", goTitle: "Case Break", }, @@ -596,6 +633,7 @@ func TestAll(t *testing.T) { goPascal: "ID", camel: "id", goCamel: "id", + header: "Id", title: "Id", goTitle: "ID", }, @@ -611,6 +649,7 @@ func TestAll(t *testing.T) { goPascal: "UserID", camel: "userId", goCamel: "userID", + header: "User-Id", title: "User Id", goTitle: "User ID", }, @@ -626,6 +665,7 @@ func TestAll(t *testing.T) { goPascal: "JSONBlob", camel: "jsonBlob", goCamel: "jsonBlob", + header: "Json-Blob", title: "Json Blob", goTitle: "JSON Blob", }, @@ -641,6 +681,7 @@ func TestAll(t *testing.T) { goPascal: "HTTPStatusCode", camel: "httpStatusCode", goCamel: "httpStatusCode", + header: "Http-Status-Code", title: "Http Status Code", goTitle: "HTTP Status Code", }, @@ -656,6 +697,7 @@ func TestAll(t *testing.T) { goPascal: "FreeBsdAndSslErrorAreNotGolangInitialisms", camel: "freeBsdAndSslErrorAreNotGolangInitialisms", goCamel: "freeBsdAndSslErrorAreNotGolangInitialisms", + header: "Free-Bsd-And-Ssl-Error-Are-Not-Golang-Initialisms", title: "Free Bsd And Ssl Error Are Not Golang Initialisms", goTitle: "Free Bsd And Ssl Error Are Not Golang Initialisms", }, @@ -671,6 +713,7 @@ func TestAll(t *testing.T) { goPascal: "David'sComputer", camel: "david'sComputer", goCamel: "david'sComputer", + header: "David's-Computer", title: "David's Computer", goTitle: "David's Computer", }, @@ -686,6 +729,7 @@ func TestAll(t *testing.T) { goPascal: "ÜnicodeSupportForÆthelredAndØyvind", camel: "ünicodeSupportForÆthelredAndØyvind", goCamel: "ünicodeSupportForÆthelredAndØyvind", + header: "Ünicode-Support-For-Æthelred-And-Øyvind", title: "Ünicode Support For Æthelred And Øyvind", goTitle: "Ünicode Support For Æthelred And Øyvind", }, @@ -701,6 +745,7 @@ func TestAll(t *testing.T) { goPascal: "Http200", camel: "http200", goCamel: "http200", + header: "Http200", title: "Http200", goTitle: "Http200", }, @@ -716,6 +761,7 @@ func TestAll(t *testing.T) { goPascal: "NumberSplittingVersion1.0r3", camel: "numberSplittingVersion1.0r3", goCamel: "numberSplittingVersion1.0r3", + header: "Number-Splitting-Version1.0r3", title: "Number Splitting Version1.0r3", goTitle: "Number Splitting Version1.0r3", }, @@ -731,6 +777,7 @@ func TestAll(t *testing.T) { goPascal: "WhenYouHaveAComma,OddResults", camel: "whenYouHaveAComma,OddResults", goCamel: "whenYouHaveAComma,OddResults", + header: "When-You-Have-A-Comma,-Odd-Results", title: "When You Have A Comma, Odd Results", goTitle: "When You Have A Comma, Odd Results", }, @@ -746,6 +793,7 @@ func TestAll(t *testing.T) { goPascal: "OrdinalNumbersWork:1st2ndAnd3rdPlace", camel: "ordinalNumbersWork:1st2ndAnd3rdPlace", goCamel: "ordinalNumbersWork:1st2ndAnd3rdPlace", + header: "Ordinal-Numbers-Work:-1st-2nd-And-3rd-Place", title: "Ordinal Numbers Work: 1st 2nd And 3rd Place", goTitle: "Ordinal Numbers Work: 1st 2nd And 3rd Place", }, @@ -761,6 +809,7 @@ func TestAll(t *testing.T) { goPascal: "BadUTF8���", camel: "badUtf8���", goCamel: "badUTF8���", + header: "Bad-Utf8-���", title: "Bad Utf8 ���", goTitle: "Bad UTF8 ���", }, @@ -778,6 +827,7 @@ func TestAll(t *testing.T) { goPascal: ToGoPascal(test.input), camel: ToCamel(test.input), goCamel: ToGoCamel(test.input), + header: ToHeader(test.input), title: ToCase(test.input, TitleCase, ' '), goTitle: ToGoCase(test.input, TitleCase, ' '), }