Skip to content

Commit c522a3a

Browse files
committed
moves example to test
1 parent acaf276 commit c522a3a

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

converter_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package caps_test
22

33
import (
4+
"fmt"
45
"testing"
56

67
"github.com/chanced/caps"
@@ -106,3 +107,19 @@ func TestConverterTableOps(t *testing.T) {
106107
// t.Errorf("expected \"WSS\", got \"%s\"", wss.Screaming)
107108
// }
108109
}
110+
111+
type MyConverter struct{}
112+
113+
func (MyConverter) Convert(req caps.ConvertRequest) string {
114+
res := caps.DefaultConverter.Convert(req)
115+
if req.Style == caps.StyleLowerCamel && req.ReplaceStyle == caps.ReplaceStyleCamel && res == "id" {
116+
return "_id"
117+
}
118+
return res
119+
}
120+
121+
func ExampleWithConverter() {
122+
fmt.Println(caps.ToLowerCamel("id", caps.WithConverter(MyConverter{}), caps.WithReplaceStyle(caps.ReplaceStyleCamel)))
123+
// Output:
124+
// _id
125+
}

examples_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,3 @@ func ExampleToTitle() {
7878
// Output:
7979
// This Is An Example ID 32
8080
}
81-
82-
type MyConverter struct{}
83-
84-
func (MyConverter) Convert(req caps.ConvertRequest) string {
85-
res := caps.DefaultConverter.Convert(req)
86-
if req.Style == caps.StyleLowerCamel && req.ReplaceStyle == caps.ReplaceStyleCamel && res == "id" {
87-
return "_id"
88-
}
89-
return res
90-
}
91-
92-
func ExampleWithConverter() {
93-
fmt.Println(caps.ToLowerCamel("id", caps.WithConverter(MyConverter{}), caps.WithReplaceStyle(caps.ReplaceStyleCamel)))
94-
// Output:
95-
// _id
96-
}

0 commit comments

Comments
 (0)