Documentation ¶
Index ¶
- Constants
- func EmbeddedTests() fs.FS
- type CommandParser
- type Parser
- type Runner
- type Test
- func (r Test) CompareJSON(want, have interface{}) Test
- func (r Test) CompareTOML(want, have interface{}) Test
- func (t Test) Failed() bool
- func (t Test) ReadInput(fsys fs.FS) (path, data string, err error)
- func (t Test) ReadWant(fsys fs.FS) (path, data string, err error)
- func (t *Test) ReadWantJSON(fsys fs.FS) (v interface{}, err error)
- func (t *Test) ReadWantTOML(fsys fs.FS) (v interface{}, err error)
- func (t Test) Run(p Parser, fsys fs.FS) Test
- func (t Test) Type() testType
- type Tests
Constants ¶
const ( TypeValid testType = iota TypeInvalid )
Variables ¶
This section is empty.
Functions ¶
func EmbeddedTests ¶
EmbeddedTests are the tests embedded in toml-test, rooted to the "test/" directory.
Types ¶
type CommandParser ¶
type CommandParser struct {
// contains filtered or unexported fields
}
CommandParser calls an external command.
func NewCommandParser ¶
func NewCommandParser(fsys fs.FS, cmd []string) CommandParser
type Parser ¶
type Parser interface { // Encode a JSON string to TOML. // // The output is the TOML string; if outputIsError is true then it's assumed // that an encoding error occurred. // // An error return should only be used in case an unrecoverable error // occurred; failing to encode to TOML is not an error, but the encoder // unexpectedly panicking is. Encode(jsonInput string) (output string, outputIsError bool, err error) // Decode a TOML string to JSON. The same semantics as Encode apply. Decode(tomlInput string) (output string, outputIsError bool, err error) }
A Parser instance is used to call the TOML parser we test.
By default this is done through an external command.
type Runner ¶
type Runner struct { Files fs.FS // Test files. Encoder bool // Are we testing an encoder? RunTests []string // Tests to run; run all if blank. SkipTests []string // Tests to skip. Parser Parser // Send data to a parser. Version string // TOML version to run tests for. }
Runner runs a set of tests.
The validity of the parameters is not checked extensively; the caller should verify this if need be. See ./cmd/toml-test for an example.
type Test ¶
type Test struct { Path string // Path of test, e.g. "valid/string-test" Skipped bool // Skipped this test? Failure string // Failure message. Key string // TOML key the failure occured on; may be blank. Encoder bool // Encoder test? Input string // The test case that we sent to the external program. Output string // Output from the external program. Want string // The output we want. OutputFromStderr bool // The Output came from stderr, not stdout. }
Result is the result of a single test.
func (Test) CompareJSON ¶
CompareJSON compares the given arguments.
The returned value is a copy of Test with Failure set to a (human-readable) description of the first element that is unequal. If both arguments are equal, Test is returned unchanged.
reflect.DeepEqual could work here, but it won't tell us how the two structures are different.
func (Test) CompareTOML ¶
CompareTOML compares the given arguments.
The returned value is a copy of Test with Failure set to a (human-readable) description of the first element that is unequal. If both arguments are equal Test is returned unchanged.
Reflect.DeepEqual could work here, but it won't tell us how the two structures are different.