xpathtest

package
v0.0.0-...-17f8324 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: BSD-3-Clause, MPL-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Brk         = "----\n"
	CrtNS       = "CreateNodeSet:\t\t"
	FiltNS      = "FilterNodeSet:\t\t"
	IgnPfxs     = "\n\nIf we ignore prefixes, we now get:\n\n"
	InstELP     = "Instr:\tevalLocPath"
	InstELPPS   = "Instr:\tevalLocPath(PredStart)"
	InstESM     = "Instr:\tevalSubMachine"
	InstLrefEq  = "Instr:\tlrefEquals"
	InstLrefPE  = "Instr:\tlrefPredEnd"
	InstLrefPS  = "Instr:\tlrefPredStart"
	InstNtPsh_B = "Instr:\tnameTestPush\t{"
	InstNumPsh  = "Instr:\tnumpush\t\t"
	InstPoPsh   = "Instr:\tpathOperPush\t"
	InstStore   = "Instr:\tstore"
	ModName     = "xpathNodeTestModule"
	PredMatch   = "Pred:\tMATCH\n"
	PredNoMatch = "Pred:\tNo Match\n"
	Run         = "Run\t"
	Stack       = "Stack:\t"
	StNS        = "Stack:\tNODESET\t\t"
	StNT_B      = "Stack:\tNAMETEST\t{"
	StNum       = "Stack:\tNUMBER\t\t"
	StPO        = "Stack:\tPATHOPER\t"
	Tab3        = "\t\t\t"
	T_ApNS      = "\tApply: NODESET\t\t"
	T_ApNT_B    = "\tApply: NAMETEST\t{"
	T_ApPO      = "\tApply: PATHOPER\t"
	T_PO_T      = "\tPATHOPER\t"
	T_NS_T      = "\tNODESET\t\t"
	T_NT_TB     = "\tNAMETEST\t{"
	T_UNS       = "Using stacked nodeset:\n"
	ValPath     = "ValidatePath:\t\tCtx: "
)

This file contains strings used in printing out the operation of a machine. The definitions are separate to those in production code so if the format changes, we are made aware of it. Otherwise it is possible that 2 strings could get swapped in production code and we would not spot it in test code.

Extracting these strings has the benefit that they appear in black in emacs versus the brown for 'text in quotes' so you can see the details that change in each line more clearly. More to the point, all the generic stuff can now be easily changed in a single place.

In some cases, leading or trailing symbols are explicitly stated so it is easier to construct the expOut strings.

T = Tab B = Brace ('{')

View Source
const (
	Container nodeType = iota
	ListEntry
	LeafList
	Leaf
)
View Source
const (
	TestModule = "xpathNodeTestModule"
)

Variables

This section is empty.

Functions

func Indent

func Indent(input string) string

Types

type TNode

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

func CreateTree

func CreateTree(t *testing.T, partialNodes []xutils.PathType) *TNode

Takes a set of partially defined test nodes and stitches them together into a tree. Each element of a partialNode can be of different types, and is specified in partial nodes using the following syntax:

- Container : string - EphemeralCont : string$ - List : string/key+value - LeafList : string@value - Leaf : string+value - EmptyLeaf : string%

func NewTContainer

func NewTContainer(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
) *TNode

func NewTEmptyLeaf

func NewTEmptyLeaf(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
) *TNode

func NewTEphemeralContainer

func NewTEphemeralContainer(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
) *TNode

func NewTLeaf

func NewTLeaf(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
	value string,
) *TNode

func NewTLeafList

func NewTLeafList(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
	value string,
) *TNode

func NewTLeafOrLeafList

func NewTLeafOrLeafList(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
	value string,
	ntype nodeType,
) *TNode

func NewTListEntry

func NewTListEntry(
	root *TNode,
	startPath xutils.PathType,
	module string,
	name string,
	key, keyValue string,
) *TNode

func (*TNode) EqualTo

func (t1 *TNode) EqualTo(n2 xutils.XpathNode) error

We don't fully construct our expected testnodes into a tree, so we can't use the standard equalTo() function for XpathNodes. Instead we do it in rather long-winded fashion.

func (*TNode) FindFirstNode

func (testnode *TNode) FindFirstNode(path xutils.PathType) *TNode

Find first node that matches (ie for list entries, we're only interested in finding an entry with the path, not a specific one. Start at root

func (*TNode) String

func (testnode *TNode) String() string

Pretty-print a testnode for debug.

func (*TNode) XChildren

func (testnode *TNode) XChildren(
	filter xutils.XFilter,
	sortSpec xutils.SortSpec,
) []xutils.XpathNode

func (*TNode) XIsEphemeral

func (testnode *TNode) XIsEphemeral() bool

func (*TNode) XIsLeaf

func (testnode *TNode) XIsLeaf() bool

func (*TNode) XIsLeafList

func (testnode *TNode) XIsLeafList() bool

func (*TNode) XIsNonPresCont

func (testnode *TNode) XIsNonPresCont() bool

func (*TNode) XListKeyMatches

func (testnode *TNode) XListKeyMatches(key xml.Name, val string) bool

func (*TNode) XListKeys

func (testnode *TNode) XListKeys() []xutils.NodeRefKey

func (*TNode) XName

func (testnode *TNode) XName() string

func (*TNode) XParent

func (testnode *TNode) XParent() xutils.XpathNode

func (*TNode) XPath

func (testnode *TNode) XPath() xutils.PathType

func (*TNode) XRoot

func (testnode *TNode) XRoot() xutils.XpathNode

func (*TNode) XValue

func (testnode *TNode) XValue() string

type TNodeSet

type TNodeSet []*TNode

Jump to

Keyboard shortcuts

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