Documentation
¶
Overview ¶
Package enum implements the enum generator for testkit. It scans const blocks of named types and generates exhaustiveness, distinctness, and stringer tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
PackageName string
ImportPath string // source package import path (empty if same package)
PkgQualifier string // "store" or "" for same package
Enums []TypeData
}
Data is the top-level template data for an enum generation run.
func Analyze ¶
Analyze builds Data by scanning the package for const blocks of the given named types.
func (*Data) HasContent ¶
HasContent reports whether there are any enums to test.
func (*Data) HasStringer ¶
HasStringer reports whether any enum has a String() method.
type Generator ¶
type Generator struct{}
Generator produces exhaustiveness tests for Go enum types.
type TypeData ¶
type TypeData struct {
TypeName string // "Status"
Values []Value // sorted by name
MaxValue int64 // highest iota value for boundary test
HasString bool // true if the type has a String() string method
HasParse bool // true if Parse<Type>(string) (<Type>, error) exists
ParseFunc string // "ParseStatus"
HasMarshalText bool // true if the type implements encoding.TextMarshaler/TextUnmarshaler
HasMarshalJSON bool // true if the type implements json.Marshaler/json.Unmarshaler
ZeroValueName string // "StatusPending" — the constant with IntValue == 0
}
TypeData holds one enum type and its constant values.
Click to show internal directories.
Click to hide internal directories.