wildcards

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package wildcards implements helper to compare text with wildcards in tests.

Inspired by PhpUnit "assertStringMatchesFormat".

Supported wildcards:
  %e: Represents a directory separator, for example / on Linux.
  %s: One or more of anything (character or white space) except the end of line character.
  %S: Zero or more of anything (character or white space) except the end of line character.
  %a: One or more of anything (character or white space) including the end of line character.
  %A: Zero or more of anything (character or white space) including the end of line character.
  %w: Zero or more white space characters.
  %i: A signed integer value, for example +3142, -3142.
  %d: An unsigned integer value, for example 123456.
  %x: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F.
  %f: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10.
  %c: A single character of any sort.
  %%: A literal percent character: %.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t assert.TestingT, expected string, actual string, msgAndArgs ...any) bool

Assert compares two texts and allows using wildcards in expected value, see ToRegexp function.

func Compare added in v0.2.0

func Compare(expected string, actual string) error

Compare compares two texts and allows using wildcards in expected value, see ToRegexp function.

func EscapeWhitespaces

func EscapeWhitespaces(input string) string

EscapeWhitespaces escapes all whitespaces except new line -> for clearer difference in diff output.

func ToRegexp

func ToRegexp(input string) string

ToRegexp converts string with wildcards to regexp, so it can be used in assert.Regexp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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