-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
57 lines (50 loc) · 1.21 KB
/
example_test.go
File metadata and controls
57 lines (50 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package strings2_test
import (
"fmt"
"github.com/arran4/strings2"
)
func ExampleToCamelCase() {
words := []strings2.Word{
strings2.SingleCaseWord("hello"),
strings2.SingleCaseWord("world"),
}
res, _ := strings2.ToCamelCase(words)
fmt.Println(res)
// Output: helloWorld
}
func ExampleToPascalCase() {
words := []strings2.Word{
strings2.SingleCaseWord("hello"),
strings2.SingleCaseWord("world"),
}
res, _ := strings2.ToPascalCase(words)
fmt.Println(res)
// Output: HelloWorld
}
func ExampleToKebabCase() {
words := []strings2.Word{
strings2.SingleCaseWord("hello"),
strings2.SingleCaseWord("world"),
}
res, _ := strings2.ToKebabCase(words)
fmt.Println(res)
// Output: hello-world
}
func ExampleToSnakeCase() {
words := []strings2.Word{
strings2.SingleCaseWord("hello"),
strings2.SingleCaseWord("world"),
}
res, _ := strings2.ToSnakeCase(words)
fmt.Println(res)
// Output: hello_world
}
func ExampleToFormattedCase() {
words := []strings2.Word{
strings2.SingleCaseWord("hello"),
strings2.SingleCaseWord("world"),
}
// Screaming snake case
fmt.Println(strings2.ToFormattedCase(words, strings2.OptionCaseMode(strings2.CMScreaming), strings2.OptionDelimiter("_")))
// Output: HELLO_WORLD
}