testutil

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dedent

func Dedent(s string) string

Dedent strips leading tabs from every line of a string, taking a hint of how many tabs should be stripped from the number of consecutive tabs found on the first non-empty line. Dedent also strips one leading blank line if it contains nothing but the linebreak.

If later lines have fewer leading tab characters than the depth we intuited from the first line, then stripping will still only remove tab characters.

Roughly, Dedent is "Do What I Mean" to normalize a heredoc string that contains leading indentation to make it congruent with the surrounding source code.

func DedentBytes

func DedentBytes(bs []byte) []byte

DedentBytes is identically to Dedent, but works on a byte slice.

func NewSimpleBytes added in v0.21.0

func NewSimpleBytes(value []byte) datamodel.Node

NewSimpleBytes is identical to basicnode.NewBytes but the returned node doesn't implement LargeBytesNode, which can be useful for testing cases where we want to exercise non-LBN code paths.

Types

type MultiByteNode added in v0.21.0

type MultiByteNode struct {
	// contains filtered or unexported fields
}

MultiByteNode is a node that is a concatenation of multiple byte slices. It's not particularly sophisticated but lets us exercise LargeBytesNode in a non-trivial way. The novel behaviour of Read() and Seek() on the AsLargeBytes is similar to that which would be expected from a LBN ADL, such as UnixFS sharded files.

func NewMultiByteNode added in v0.21.0

func NewMultiByteNode(bytes ...[]byte) MultiByteNode

func (MultiByteNode) AsBool added in v0.21.0

func (mbn MultiByteNode) AsBool() (bool, error)

func (MultiByteNode) AsBytes added in v0.21.0

func (mbn MultiByteNode) AsBytes() ([]byte, error)

func (MultiByteNode) AsFloat added in v0.21.0

func (mbn MultiByteNode) AsFloat() (float64, error)

func (MultiByteNode) AsInt added in v0.21.0

func (mbn MultiByteNode) AsInt() (int64, error)

func (MultiByteNode) AsLargeBytes added in v0.21.0

func (mbn MultiByteNode) AsLargeBytes() (io.ReadSeeker, error)
func (mbn MultiByteNode) AsLink() (datamodel.Link, error)

func (MultiByteNode) AsNode added in v0.21.0

func (mbn MultiByteNode) AsNode() (datamodel.Node, error)

func (MultiByteNode) AsString added in v0.21.0

func (mbn MultiByteNode) AsString() (string, error)

func (MultiByteNode) IsAbsent added in v0.21.0

func (mbn MultiByteNode) IsAbsent() bool

func (MultiByteNode) IsNull added in v0.21.0

func (mbn MultiByteNode) IsNull() bool

func (MultiByteNode) Kind added in v0.21.0

func (mbn MultiByteNode) Kind() datamodel.Kind

func (MultiByteNode) Length added in v0.21.0

func (mbn MultiByteNode) Length() int64

func (MultiByteNode) ListIterator added in v0.21.0

func (mbn MultiByteNode) ListIterator() datamodel.ListIterator

func (MultiByteNode) LookupByIndex added in v0.21.0

func (mbn MultiByteNode) LookupByIndex(idx int64) (datamodel.Node, error)

func (MultiByteNode) LookupByNode added in v0.21.0

func (mbn MultiByteNode) LookupByNode(key datamodel.Node) (datamodel.Node, error)

func (MultiByteNode) LookupBySegment added in v0.21.0

func (mbn MultiByteNode) LookupBySegment(seg datamodel.PathSegment) (datamodel.Node, error)

func (MultiByteNode) LookupByString added in v0.21.0

func (mbn MultiByteNode) LookupByString(key string) (datamodel.Node, error)

func (MultiByteNode) MapIterator added in v0.21.0

func (mbn MultiByteNode) MapIterator() datamodel.MapIterator

func (MultiByteNode) Prototype added in v0.21.0

func (mbn MultiByteNode) Prototype() datamodel.NodePrototype

func (MultiByteNode) Size added in v0.21.0

func (mbn MultiByteNode) Size() int

func (MultiByteNode) TotalLength added in v0.21.0

func (mbn MultiByteNode) TotalLength() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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