fixtures

package
v0.89.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Token stream test fixtures. This is a public package because it is used by tests in the `json`, `cbor`, and `obj` packages. It should not be seen in the imports outside of testing.

Index

Constants

This section is empty.

Variables

View Source
var SequenceMap map[string]Sequence

Sequences indexed by title.

View Source
var Sequences []Sequence

Functions

func StompLengths

func StompLengths(v []tok.Token)

StompLengths in-place mutates all tokens to have length=-1 if length is a relevant property for that Token.Type, and to 0 otherwise.

Types

type Sequence

type Sequence struct {
	Title  string
	Tokens Tokens
}

func (Sequence) Append

func (s Sequence) Append(tok Token) Sequence

Returns a copy of the sequence with the given token appened. This is mostly useful to test failure modes, like appending an invalid token at the end so decoder lengths match up.

func (Sequence) Clone

func (s Sequence) Clone() Sequence

Returns a copy of the sequence with no shared memory. This is useful when writing tests that use almost-the-fixture but you want to change one token.

func (Sequence) SansLengthInfo

func (s Sequence) SansLengthInfo() Sequence

Returns a copy of the sequence with all length info at the start of maps and arrays stripped. Use this when testing e.g. json and cbor-in-stream-mode, which doesn't know lengths.

type Tokens

type Tokens []Token

func (Tokens) Clone

func (ts Tokens) Clone() Tokens

Returns a copy of the token slice with no shared memory. This is useful when writing tests that use almost-the-fixture but you want to change one token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL