package tomltest
import "github.com/BurntSushi/toml/internal/toml-test"
Index ¶
- Constants
- func EmbeddedTests() fs.FS
- type CommandParser
- func NewCommandParser(fsys fs.FS, cmd []string) CommandParser
- func (c CommandParser) Decode(input string) (string, bool, error)
- func (c CommandParser) Encode(input string) (output string, outputIsError bool, err error)
- type Parser
- type Runner
- type 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 )
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
func (CommandParser) Decode ¶
func (c CommandParser) Decode(input string) (string, bool, error)
func (CommandParser) Encode ¶
func (c CommandParser) Encode(input string) (output string, outputIsError bool, err error)
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. }
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.
func (Runner) List ¶
List all tests in Files.
func (Runner) Run ¶
Run all tests listed in t.RunTests.
TODO: give option to: - Run all tests with \n replaced with \r\n - Run all tests with '# comment' appended to every line.
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) Failed ¶
func (Test) ReadInput ¶
ReadInput reads the file sent to the encoder.
func (Test) ReadWant ¶
func (*Test) ReadWantJSON ¶
func (*Test) ReadWantTOML ¶
func (Test) Run ¶
Run this test.
func (Test) Type ¶
func (t Test) Type() testType
Test type: "valid", "invalid"
type Tests ¶
Tests are tests to run.
Source Files ¶
- Version
- v0.4.1
- Published
- Aug 5, 2021
- Platform
- darwin/amd64
- Imports
- 15 packages
- Last checked
- 1 day ago –
Tools for package owners.