jacl

package
v0.0.0-...-988b307 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

README

jacl

Just Another Comparison Library.

This is a small utility intended to ease verifying conditions for complex testing. It is an offshot from a much more extensive library at github.com/hackborn/jacl.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(target any, terms ...string) error

Run compares a list of terms against a target. Target can be anything. Terms are described by the grammar {term} = {path}{comparison_operator}{value} Where {path} is a "/" separated list of identifiers {comparison_operator} is "=" {value} is a string {path} identifiers can be either an integer to index slices, or a string for named fields. Example term: "0/Name=Ireland" where the target is a slice of structs that have a Name field.

func RunErr

func RunErr(have, want error) error

RunErr compares two errors, returning if they do not match. I use a soft definition of "match"; the errors can be different, it just checks if they are both nil or not. Ideally, error messages are not part of an API.

func RunOpts

func RunOpts(opts Opts, target any, terms ...string) error

RunOpts compares a list of terms against a target. Target can be anything. See Run docs for a decription of target and terms. Opts adds some configuration options, see Opts docs for a description.

Types

type Opts

type Opts struct {
	// If RawValues is true then the value tokens are left
	// completely unprocessed.
	// If it is false, then processing is applied:
	// * Two single quotes (”) are replaced with a double quote (").
	// Default is false.
	RawValues bool
}

Jump to

Keyboard shortcuts

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