package
0.2.1
Repository: https://github.com/expectto/be.git
Documentation: pkg.go.dev

# README

be_string

-- import "github.com/expectto/be/be_string"

Package be_string provides Be matchers for string-related assertions.

Usage

func ContainingCharacters

func ContainingCharacters(characters string) types.BeMatcher

ContainingCharacters succeeds if actual is a string containing all characters from a given set

func ContainingOnlyCharacters

func ContainingOnlyCharacters(characters string) types.BeMatcher

ContainingOnlyCharacters succeeds if actual is a string containing only characters from a given set

func ContainingSubstring

func ContainingSubstring(substr string) types.BeMatcher

ContainingSubstring succeeds if actual is a string containing only characters from a given set

func EmptyString

func EmptyString() types.BeMatcher

EmptyString succeeds if actual is an empty string. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func Float

func Float() types.BeMatcher

Float succeeds if actual is a string representing a valid floating-point number. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func LowerCaseOnly

func LowerCaseOnly() types.BeMatcher

LowerCaseOnly succeeds if actual is a string containing only lowercase characters. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func MatchTemplate

func MatchTemplate(template string, vars ...*V) types.BeMatcher

MatchTemplate succeeds if actual matches given template pattern. Provided template must have {{Field}} placeholders. Each distinct placeholder from template requires a var to be passed in list of vars. Var can be a raw value or a matcher

E.g.

Expect(someString).To(be_string.MatchTemplate("Hello {{Name}}. Your number is {{Number}}", be_string.Var("Name", "John"), be_string.Var("Number", 3)))
Expect(someString).To(be_string.MatchTemplate("Hello {{Name}}. Good bye, {{Name}}.", be_string.Var("Name", be_string.Titled()))

func MatchWildcard

func MatchWildcard(pattern string) types.BeMatcher

MatchWildcard succeeds if actual matches given wildcard pattern. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func NonEmptyString

func NonEmptyString() types.BeMatcher

NonEmptyString succeeds if actual is not an empty string. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func Only

func Only(option StringOption) types.BeMatcher

Only succeeds if actual is a string containing only characters described by given options Only() defaults to empty string matching

func Titled

func Titled(languageArg ...language.Tag) types.BeMatcher

Titled succeeds if actual is a string with the first letter of each word capitalized. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func UpperCaseOnly

func UpperCaseOnly() types.BeMatcher

UpperCaseOnly succeeds if actual is a string containing only uppercase characters. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func ValidEmail

func ValidEmail() types.BeMatcher

ValidEmail succeeds if actual is a valid email. Actual must be a string-like value (can be adjusted via SetStringFormat method).

func ValidateStringOption

func ValidateStringOption(opt StringOption, r rune) bool

type V

type V struct {
	Name    string
	Matcher types.BeMatcher
}

func Var

func Var(name string, matching any) *V

Var creates a var used for replacing placeholders for templates in MatchTemplate

# Functions

ContainingCharacters succeeds if actual is a string containing all characters from a given set.
ContainingOnlyCharacters succeeds if actual is a string containing only characters from a given set.
ContainingSubstring succeeds if actual is a string containing only characters from a given set.
EmptyString succeeds if actual is an empty string.
Float succeeds if actual is a string representing a valid floating-point number.
LowerCaseOnly succeeds if actual is a string containing only lowercase characters.
MatchTemplate succeeds if actual matches given template pattern.
MatchWildcard succeeds if actual matches given wildcard pattern.
NonEmptyString succeeds if actual is not an empty string.
Only succeeds if actual is a string containing only characters described by given options Only() defaults to empty string matching Only(Alpha|Numeric) succeeds if string contains only from alphabetic and numeric characters Available options are: Alpha, Numeric, Whitespace, Dots, Punctuation, SpecialCharacters TODO: special-characters are not supported yet.
Titled succeeds if actual is a string with the first letter of each word capitalized.
UpperCaseOnly succeeds if actual is a string containing only uppercase characters.
ValidEmail succeeds if actual is a valid email.

# Variables

No description provided by the author