strings

package
v0.0.0-...-a7d1dd0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyPattern

func AnyPattern(pattern string) func(matcher *base.Matcher) *base.Matcher

Returns a short-circuiting function that applies the matcher to each occurrence of the pattern in an input string, until a matching pattern is found (in which case the matcher successfully matches) or all matching instances are exhausted (in which case the output matcher fails to match).

For example:

AnyPattern("x.")(EqualTo("xy"))

would match:

"six sax are sexy" (three matches of "x.", third is "xy")

but not:

"pox pix are pixelated" (three matches of "x.", none is "xy")

func AnyPatternGroup

func AnyPatternGroup(pattern string, group int) func(matcher *base.Matcher) *base.Matcher

Variant of AnyPattern() that uses the given subgroup of the pattern.

func Contains

func Contains(substring string) *base.Matcher

Matches strings that contain the given substring.

func EachPattern

func EachPattern(pattern string) func(matcher *base.Matcher) *base.Matcher

Returns a short-circuiting function that applies the matcher to each occurrence of the pattern in an input string, until a failing pattern is found (in which case the output matcher fails to match) or all matching instances are exhausted (in which case the output matcher successfully matches).

For example:

EachPattern("q.")(EqualTo("qu"))

would match:

"quick quack mq" (two matches of "q.", both equal to "qu")

but not:

"quick qs for mq" (two matches of "q.", second is not "qu")

func EachPatternGroup

func EachPatternGroup(pattern string, group int) func(matcher *base.Matcher) *base.Matcher

Variant of EachPattern() that uses the given subgroup of the pattern.

func EqualToIgnoringCase

func EqualToIgnoringCase(expected string) *base.Matcher

func HasPattern

func HasPattern(pattern string) *base.Matcher

Matches strings that contain the given regexp pattern, using the same syntax as the standard regexp package.

func HasPrefix

func HasPrefix(prefix string) *base.Matcher

Matches strings that begin with the given prefix.

func HasSuffix

func HasSuffix(suffix string) *base.Matcher

Matches strings that end with the given prefix.

func OnPattern

func OnPattern(pattern string) func(matcher *base.Matcher) *base.Matcher

Returns a function that applies the matcher to the first occurrence of the pattern in an input string.

For example:

OnPattern("h.s")(EqualTo("his"))

would match:

"hers and his" (because the first instance of "h.s" is equal to "his")

but none of:

"just hers" (no instances of "h.s")
"has chisel" (the first instance of "h.s" is not "his")

func OnPatternGroup

func OnPatternGroup(pattern string, group int) func(matcher *base.Matcher) *base.Matcher

Variant of OnPattern() that uses the given subgroup of the pattern.

func ToGoString

func ToGoString(matcher *base.Matcher) *base.Matcher

Applies the given matcher to the result of writing the input object's to a string by using fmt.Sprintf("%#v", object).

func ToLen

func ToLen(matcher *base.Matcher) *base.Matcher

Creates a new matcher that applies the given matcher to the result of converting an input string its length. (using the `len()` builtin). If the input value is not a string, the matcher fails to match.

func ToLower

func ToLower(matcher *base.Matcher) *base.Matcher

Creates a new matcher that applies the given matcher to the result of converting an input string to lowercase (using strings.ToLower). If the input value is not a string, the matcher fails to match.

func ToString

func ToString(matcher *base.Matcher) *base.Matcher

Applies the given matcher to the result of writing the input object's to a string by using fmt.Sprintf("%v", object).

func ToUpper

func ToUpper(matcher *base.Matcher) *base.Matcher

Creates a new matcher that applies the given matcher to the result of converting an input string to uppercase (using strings.ToUpper). If the input value is not a string, the matcher fails to match.

Types

type WithPatternClause

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

Jump to

Keyboard shortcuts

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