ReAll

func ReAll(reg interface{}, capture interface{}) TestDeep

ReAll operator allows to successively apply a regexp on a string (or convertible), []byte, error or fmt.Stringer interface (error interface is tested before fmt.Stringer) and to match its groups contents.

reg is the regexp. It can be a string that is automatically compiled using regexp.MustCompile, or a *regexp.Regexp.

capture is used to match the contents of regexp groups. Groups are presented as a []string or [][]byte depending the original matched data. Note that an other operator can be used here.

td.Cmp(t, "John Doe",
  td.ReAll(`(\w+)(?: |\z)`, []string{"John", "Doe"})) // succeeds
td.Cmp(t, "John Doe",
  td.ReAll(`(\w+)(?: |\z)`, td.Bag("Doe", "John"))) // succeeds

See also ReAll godoc.

Examples

Capture example
CaptureComplex example
CompiledCapture example
CompiledCaptureComplex example

CmpReAll shortcut

func CmpReAll(t TestingT, got interface{}, reg interface{}, capture interface{}, args ...interface{}) bool

CmpReAll is a shortcut for:

td.Cmp(t, got, td.ReAll(reg, capture), args...)

See above for details.

Returns true if the test is OK, false if it fails.

args… are optional and allow to name the test. This name is used in case of failure to qualify the test. If len(args) > 1 and the first item of args is a string and contains a ‘%’ rune then fmt.Fprintf is used to compose the name, else args are passed to fmt.Fprint. Do not forget it is the name of the test, not the reason of a potential failure.

See also CmpReAll godoc.

Examples

Capture example
CaptureComplex example
CompiledCapture example
CompiledCaptureComplex example

T.ReAll shortcut

func (t *T) ReAll(got interface{}, reg interface{}, capture interface{}, args ...interface{}) bool

ReAll is a shortcut for:

t.Cmp(got, td.ReAll(reg, capture), args...)

See above for details.

Returns true if the test is OK, false if it fails.

args… are optional and allow to name the test. This name is used in case of failure to qualify the test. If len(args) > 1 and the first item of args is a string and contains a ‘%’ rune then fmt.Fprintf is used to compose the name, else args are passed to fmt.Fprint. Do not forget it is the name of the test, not the reason of a potential failure.

See also T.ReAll godoc.

Examples

Capture example
CaptureComplex example
CompiledCapture example
CompiledCaptureComplex example