mirror of https://github.com/dmarkham/enumer.git
Merge 7e279f03c6
into bcbe6173c3
This commit is contained in:
commit
eee440fa28
|
@ -183,6 +183,8 @@ name := MyTypeValue.String() // name => "my_type_value"
|
||||||
- snake-upper
|
- snake-upper
|
||||||
- kebab
|
- kebab
|
||||||
- kebab-upper
|
- kebab-upper
|
||||||
|
- dot (dot.case)
|
||||||
|
- dot-upper (DOT.CASE)
|
||||||
- lower (lowercase)
|
- lower (lowercase)
|
||||||
- upper (UPPERCASE)
|
- upper (UPPERCASE)
|
||||||
- title (TitleCase)
|
- title (TitleCase)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
// go command is not available on android
|
// go command is not available on android
|
||||||
|
|
||||||
|
//go:build !android
|
||||||
// +build !android
|
// +build !android
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
@ -89,6 +90,12 @@ func TestEndToEnd(t *testing.T) {
|
||||||
case "transform_kebab_upper.go":
|
case "transform_kebab_upper.go":
|
||||||
typeName = "KebabUpperCaseValue"
|
typeName = "KebabUpperCaseValue"
|
||||||
transformNameMethod = "kebab-upper"
|
transformNameMethod = "kebab-upper"
|
||||||
|
case "transform_dot.go":
|
||||||
|
typeName = "DotCaseValue"
|
||||||
|
transformNameMethod = "dot"
|
||||||
|
case "transform_dot_upper.go":
|
||||||
|
typeName = "DotUpperCaseValue"
|
||||||
|
transformNameMethod = "dot-upper"
|
||||||
case "transform_upper.go":
|
case "transform_upper.go":
|
||||||
typeName = "UpperCaseValue"
|
typeName = "UpperCaseValue"
|
||||||
transformNameMethod = "upper"
|
transformNameMethod = "upper"
|
||||||
|
|
|
@ -343,6 +343,14 @@ func (g *Generator) transformValueNames(values []Value, transformMethod string)
|
||||||
fn = func(s string) string {
|
fn = func(s string) string {
|
||||||
return strings.ToUpper(name.Delimit(s, '-'))
|
return strings.ToUpper(name.Delimit(s, '-'))
|
||||||
}
|
}
|
||||||
|
case "dot":
|
||||||
|
fn = func(s string) string {
|
||||||
|
return strings.ToLower(name.Delimit(s, '.'))
|
||||||
|
}
|
||||||
|
case "dot_upper", "dot-upper":
|
||||||
|
fn = func(s string) string {
|
||||||
|
return strings.ToUpper(name.Delimit(s, '.'))
|
||||||
|
}
|
||||||
case "upper":
|
case "upper":
|
||||||
fn = func(s string) string {
|
fn = func(s string) string {
|
||||||
return strings.ToUpper(s)
|
return strings.ToUpper(s)
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type DotCaseValue int
|
||||||
|
|
||||||
|
const (
|
||||||
|
DotCaseValueOne DotCaseValue = iota
|
||||||
|
DotCaseValueTwo
|
||||||
|
DotCaseValueThree
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ck(DotCaseValueOne, "dot.case.value.one")
|
||||||
|
ck(DotCaseValueTwo, "dot.case.value.two")
|
||||||
|
ck(DotCaseValueThree, "dot.case.value.three")
|
||||||
|
ck(-127, "DotCaseValue(-127)")
|
||||||
|
ck(127, "DotCaseValue(127)")
|
||||||
|
}
|
||||||
|
|
||||||
|
func ck(value DotCaseValue, str string) {
|
||||||
|
if fmt.Sprint(value) != str {
|
||||||
|
panic("transform_dot.go: " + str)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type DotUpperCaseValue int
|
||||||
|
|
||||||
|
const (
|
||||||
|
DotUpperCaseValueOne DotUpperCaseValue = iota
|
||||||
|
DotUpperCaseValueTwo
|
||||||
|
DotUpperCaseValueThree
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ck(DotUpperCaseValueOne, "DOT.UPPER.CASE.VALUE.ONE")
|
||||||
|
ck(DotUpperCaseValueTwo, "DOT.UPPER.CASE.VALUE.TWO")
|
||||||
|
ck(DotUpperCaseValueThree, "DOT.UPPER.CASE.VALUE.THREE")
|
||||||
|
ck(-127, "DotUpperCaseValue(-127)")
|
||||||
|
ck(127, "DotUpperCaseValue(127)")
|
||||||
|
}
|
||||||
|
|
||||||
|
func ck(value DotUpperCaseValue, str string) {
|
||||||
|
if fmt.Sprint(value) != str {
|
||||||
|
panic("transform_dot_upper.go: " + str)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue