Skip to content

Commit

Permalink
Add test case for -transform=lowercamel
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelBec committed Nov 27, 2019
1 parent 65723b6 commit 346a688
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func TestEndToEnd(t *testing.T) {
if name == "transform.go" {
typeName = "CamelCaseValue"
transformNameMethod = "snake"
} else if name == "transformlowercamel.go" {
typeName = "CamelCaseValue"
transformNameMethod = "lowercamel"
}

stringerCompileAndRun(t, dir, stringer, typeName, name, transformNameMethod)
Expand Down Expand Up @@ -122,4 +125,4 @@ func runInDir(dir, name string, arg ...string) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
}
25 changes: 25 additions & 0 deletions testdata/transformlowercamel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import "fmt"

type CamelCaseValue int

const (
CamelCaseValueOne CamelCaseValue = iota
CamelCaseValueTwo
CamelCaseValueThree
)

func main() {
ck(CamelCaseValueOne, "camelCaseValueOne")
ck(CamelCaseValueTwo, "camelCaseValueTwo")
ck(CamelCaseValueThree, "camelCaseValueThree")
ck(-127, "CamelCaseValue(-127)")
ck(127, "CamelCaseValue(127)")
}

func ck(value CamelCaseValue, str string) {
if fmt.Sprint(value) != str {
panic("transformlowercamel.go: " + str)
}
}

0 comments on commit 346a688

Please sign in to comment.