enumer/testdata/gap.golden

116 lines
2.6 KiB
Plaintext

const (
_GapName_0 = "TwoThree"
_GapLowerName_0 = "twothree"
_GapName_1 = "FiveSixSevenEightNine"
_GapLowerName_1 = "fivesixseveneightnine"
_GapName_2 = "Eleven"
_GapLowerName_2 = "eleven"
)
var (
_GapIndex_0 = [...]uint8{0, 3, 8}
_GapIndex_1 = [...]uint8{0, 4, 7, 12, 17, 21}
_GapIndex_2 = [...]uint8{0, 6}
)
func (i Gap) String() string {
switch {
case 2 <= i && i <= 3:
i -= 2
return _GapName_0[_GapIndex_0[i]:_GapIndex_0[i+1]]
case 5 <= i && i <= 9:
i -= 5
return _GapName_1[_GapIndex_1[i]:_GapIndex_1[i+1]]
case i == 11:
return _GapName_2
default:
return fmt.Sprintf("Gap(%d)", i)
}
}
func (Gap) Values() []string {
return GapStrings()
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _GapNoOp() {
var x [1]struct{}
_ = x[Two-(2)]
_ = x[Three-(3)]
_ = x[Five-(5)]
_ = x[Six-(6)]
_ = x[Seven-(7)]
_ = x[Eight-(8)]
_ = x[Nine-(9)]
_ = x[Eleven-(11)]
}
var _GapValues = []Gap{Two, Three, Five, Six, Seven, Eight, Nine, Eleven}
var _GapNameToValueMap = map[string]Gap{
_GapName_0[0:3]: Two,
_GapLowerName_0[0:3]: Two,
_GapName_0[3:8]: Three,
_GapLowerName_0[3:8]: Three,
_GapName_1[0:4]: Five,
_GapLowerName_1[0:4]: Five,
_GapName_1[4:7]: Six,
_GapLowerName_1[4:7]: Six,
_GapName_1[7:12]: Seven,
_GapLowerName_1[7:12]: Seven,
_GapName_1[12:17]: Eight,
_GapLowerName_1[12:17]: Eight,
_GapName_1[17:21]: Nine,
_GapLowerName_1[17:21]: Nine,
_GapName_2[0:6]: Eleven,
_GapLowerName_2[0:6]: Eleven,
}
var _GapNames = []string{
_GapName_0[0:3],
_GapName_0[3:8],
_GapName_1[0:4],
_GapName_1[4:7],
_GapName_1[7:12],
_GapName_1[12:17],
_GapName_1[17:21],
_GapName_2[0:6],
}
// GapString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func GapString(s string) (Gap, error) {
if val, ok := _GapNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _GapNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Gap values", s)
}
// GapValues returns all values of the enum
func GapValues() []Gap {
return _GapValues
}
// GapStrings returns a slice of all String values of the enum
func GapStrings() []string {
strs := make([]string, len(_GapNames))
copy(strs, _GapNames)
return strs
}
// IsAGap returns "true" if the value is listed in the enum definition. "false" otherwise
func (i Gap) IsAGap() bool {
for _, v := range _GapValues {
if i == v {
return true
}
}
return false
}