Documentation
¶
Index ¶
- func Fail(t TestingT, fatalOnFailure bool, str string, msg ...string)
- func Panic(t TestingT, fatalOnFailure bool, fn func(), expr string, msg ...string)
- func ToJSONString(v any) string
- func ToPrettyString(v any) string
- type Assertion
- func (a *Assertion) Contains(expect any, msg ...string) *Assertion
- func (a *Assertion) Equal(expect any, msg ...string) *Assertion
- func (a *Assertion) False(msg ...string) *Assertion
- func (a *Assertion) Has(expect any, msg ...string) *Assertion
- func (a *Assertion) Implements(expect any, msg ...string) *Assertion
- func (a *Assertion) Nil(msg ...string) *Assertion
- func (a *Assertion) NotEqual(expect any, msg ...string) *Assertion
- func (a *Assertion) NotNil(msg ...string) *Assertion
- func (a *Assertion) NotSame(expect any, msg ...string) *Assertion
- func (a *Assertion) Same(expect any, msg ...string) *Assertion
- func (a *Assertion) True(msg ...string) *Assertion
- func (a *Assertion) TypeOf(expect any, msg ...string) *Assertion
- type AssertionBase
- type ErrorAssertion
- func (a *ErrorAssertion) Is(target error, msg ...string) *ErrorAssertion
- func (a *ErrorAssertion) Matches(expr string, msg ...string) *ErrorAssertion
- func (a *ErrorAssertion) Nil(msg ...string) *ErrorAssertion
- func (a *ErrorAssertion) NotIs(target error, msg ...string) *ErrorAssertion
- func (a *ErrorAssertion) NotNil(msg ...string) *ErrorAssertion
- func (a *ErrorAssertion) String(expect string, msg ...string) *ErrorAssertion
- type MapAssertion
- func (a *MapAssertion[K, V]) ContainsKey(key K, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) ContainsKeyValue(key K, value V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) ContainsKeys(keys []K, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) ContainsValue(value V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) ContainsValues(values []V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) Empty(msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) Equal(expect map[K]V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) HasSameKeys(expect map[K]V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) HasSameValues(expect map[K]V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) Length(length int, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) Nil(msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotContainsKey(key K, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotContainsKeys(keys []K, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotContainsValue(value V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotContainsValues(values []V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotEmpty(msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotEqual(expect map[K]V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) NotNil(msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) SubsetOf(expect map[K]V, msg ...string) *MapAssertion[K, V]
- func (a *MapAssertion[K, V]) SupersetOf(expect map[K]V, msg ...string) *MapAssertion[K, V]
- type MockTestingT
- type Number
- type NumberAssertion
- func (a *NumberAssertion[T]) Between(lower, upper T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) Equal(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) GreaterOrEqual(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) GreaterThan(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) InDelta(expect T, delta T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) IsFinite(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) IsInf(sign int, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) IsNaN(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) LessOrEqual(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) LessThan(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) Negative(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) NotBetween(lower, upper T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) NotEqual(expect T, msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) NotNegative(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) NotPositive(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) NotZero(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) Positive(msg ...string) *NumberAssertion[T]
- func (a *NumberAssertion[T]) Zero(msg ...string) *NumberAssertion[T]
- type SliceAssertion
- func (a *SliceAssertion[T]) AllMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) AllUnique(msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) AnyMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) Contains(element T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) ContainsSlice(sub []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) Empty(msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) Equal(expect []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) HasPrefix(prefix []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) HasSuffix(suffix []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) Length(length int, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) Nil(msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NoneMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NotContains(element T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NotContainsSlice(sub []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NotEmpty(msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NotEqual(expect []T, msg ...string) *SliceAssertion[T]
- func (a *SliceAssertion[T]) NotNil(msg ...string) *SliceAssertion[T]
- type StringAssertion
- func (a *StringAssertion) Blank(msg ...string) *StringAssertion
- func (a *StringAssertion) Contains(substr string, msg ...string) *StringAssertion
- func (a *StringAssertion) Equal(expect string, msg ...string) *StringAssertion
- func (a *StringAssertion) EqualFold(expect string, msg ...string) *StringAssertion
- func (a *StringAssertion) HasPrefix(prefix string, msg ...string) *StringAssertion
- func (a *StringAssertion) HasSuffix(suffix string, msg ...string) *StringAssertion
- func (a *StringAssertion) IsAlpha(msg ...string) *StringAssertion
- func (a *StringAssertion) IsAlphaNumeric(msg ...string) *StringAssertion
- func (a *StringAssertion) IsBase64(msg ...string) *StringAssertion
- func (a *StringAssertion) IsEmail(msg ...string) *StringAssertion
- func (a *StringAssertion) IsHex(msg ...string) *StringAssertion
- func (a *StringAssertion) IsIPv4(msg ...string) *StringAssertion
- func (a *StringAssertion) IsLowerCase(msg ...string) *StringAssertion
- func (a *StringAssertion) IsNumeric(msg ...string) *StringAssertion
- func (a *StringAssertion) IsURL(msg ...string) *StringAssertion
- func (a *StringAssertion) IsUpperCase(msg ...string) *StringAssertion
- func (a *StringAssertion) JSONEqual(expect string, msg ...string) *StringAssertion
- func (a *StringAssertion) Length(length int, msg ...string) *StringAssertion
- func (a *StringAssertion) Matches(pattern string, msg ...string) *StringAssertion
- func (a *StringAssertion) NotBlank(msg ...string) *StringAssertion
- func (a *StringAssertion) NotEqual(expect string, msg ...string) *StringAssertion
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fail ¶
Fail reports an assertion failure using the provided TestingT. If fatalOnFailure is true, it calls `t.Fatal`; otherwise, it calls `t.Error`.
func Panic ¶
Panic asserts that fn panics and the panic message matches expr. It reports an error if fn does not panic or if the recovered message does not satisfy expr.
func ToJSONString ¶ added in v1.2.4
ToJSONString converts the given value to a JSON string.
func ToPrettyString ¶ added in v1.2.4
ToPrettyString converts the given value to a pretty string.
Types ¶
type Assertion ¶ added in v1.2.4
type Assertion struct { AssertionBase // contains filtered or unexported fields }
Assertion wraps a test context and a value for fluent assertions.
func (*Assertion) Contains ¶ added in v1.2.4
Contains asserts that the wrapped value v has a method named 'Contains' that returns true when passed expect. It reports an error if the method does not exist or returns false.
func (*Assertion) Equal ¶ added in v1.2.4
Equal asserts that the wrapped value v is `reflect.DeepEqual` to expect. It reports an error if the values are not deeply equal.
func (*Assertion) False ¶ added in v1.2.4
False asserts that got is false. It reports an error if the value is true.
func (*Assertion) Has ¶ added in v1.2.4
Has asserts that the wrapped value v has a method named 'Has' that returns true when passed expect. It reports an error if the method does not exist or returns false.
func (*Assertion) Implements ¶ added in v1.2.4
Implements asserts that the type of the wrapped value v implements the interface type of expect. The expect parameter must be an interface or pointer to interface. It reports an error if v does not implement the interface.
func (*Assertion) Nil ¶ added in v1.2.4
Nil asserts that got is nil. It reports an error if the value is not nil.
func (*Assertion) NotEqual ¶ added in v1.2.4
NotEqual asserts that the wrapped value v is not deeply equal to expect. It reports an error if the values are deeply equal.
func (*Assertion) NotNil ¶ added in v1.2.4
NotNil asserts that got is not nil. It reports an error if the value is nil.
func (*Assertion) NotSame ¶ added in v1.2.4
NotSame asserts that the wrapped value v and expect are not the same (using Go !=). It reports an error if v == expect.
func (*Assertion) Same ¶ added in v1.2.4
Same asserts that the wrapped value v and expect are the same (using Go ==). It reports an error if v != expect.
type AssertionBase ¶ added in v1.2.4
type AssertionBase struct {
// contains filtered or unexported fields
}
AssertionBase provides common functionality for `Assertion`.
type ErrorAssertion ¶ added in v1.2.4
type ErrorAssertion struct { AssertionBase // contains filtered or unexported fields }
ErrorAssertion provides assertion methods for values of type error. It is used to perform validations on error values in test cases.
func ThatError ¶ added in v1.2.4
func ThatError(t TestingT, v error, fatalOnFailure bool) *ErrorAssertion
ThatError returns a new ErrorAssertion for the given error value.
func (*ErrorAssertion) Is ¶ added in v1.2.4
func (a *ErrorAssertion) Is(target error, msg ...string) *ErrorAssertion
Is reports a test failure if the error is not the same as the given error.
func (*ErrorAssertion) Matches ¶ added in v1.2.4
func (a *ErrorAssertion) Matches(expr string, msg ...string) *ErrorAssertion
Matches reports a test failure if the error string does not match the given expression. It expects a non-nil error and uses the provided expression (typically a regex) to validate the error message content. Optional custom failure messages can be provided.
func (*ErrorAssertion) Nil ¶ added in v1.2.4
func (a *ErrorAssertion) Nil(msg ...string) *ErrorAssertion
Nil reports a test failure if the error is not nil.
func (*ErrorAssertion) NotIs ¶ added in v1.2.4
func (a *ErrorAssertion) NotIs(target error, msg ...string) *ErrorAssertion
NotIs reports a test failure if the error is the same as the given error.
func (*ErrorAssertion) NotNil ¶ added in v1.2.4
func (a *ErrorAssertion) NotNil(msg ...string) *ErrorAssertion
NotNil reports a test failure if the error is nil.
func (*ErrorAssertion) String ¶ added in v1.2.4
func (a *ErrorAssertion) String(expect string, msg ...string) *ErrorAssertion
String reports a test failure if the error message is not equal to the expected message.
type MapAssertion ¶ added in v1.2.4
type MapAssertion[K, V comparable] struct { AssertionBase // contains filtered or unexported fields }
MapAssertion encapsulates a map value and a test handler for making assertions on the map.
func ThatMap ¶ added in v1.2.4
func ThatMap[K, V comparable](t TestingT, v map[K]V, fatalOnFailure bool) *MapAssertion[K, V]
ThatMap returns a MapAssertion for the given testing object and map value.
func (*MapAssertion[K, V]) ContainsKey ¶ added in v1.2.4
func (a *MapAssertion[K, V]) ContainsKey(key K, msg ...string) *MapAssertion[K, V]
ContainsKey asserts that the map contains the expected key.
func (*MapAssertion[K, V]) ContainsKeyValue ¶ added in v1.2.4
func (a *MapAssertion[K, V]) ContainsKeyValue(key K, value V, msg ...string) *MapAssertion[K, V]
ContainsKeyValue asserts that the map contains the expected key-value pair.
func (*MapAssertion[K, V]) ContainsKeys ¶ added in v1.2.4
func (a *MapAssertion[K, V]) ContainsKeys(keys []K, msg ...string) *MapAssertion[K, V]
ContainsKeys asserts that the map contains all the expected keys.
func (*MapAssertion[K, V]) ContainsValue ¶ added in v1.2.4
func (a *MapAssertion[K, V]) ContainsValue(value V, msg ...string) *MapAssertion[K, V]
ContainsValue asserts that the map contains the expected value.
func (*MapAssertion[K, V]) ContainsValues ¶ added in v1.2.4
func (a *MapAssertion[K, V]) ContainsValues(values []V, msg ...string) *MapAssertion[K, V]
ContainsValues asserts that the map contains all the expected values.
func (*MapAssertion[K, V]) Empty ¶ added in v1.2.4
func (a *MapAssertion[K, V]) Empty(msg ...string) *MapAssertion[K, V]
Empty asserts that the map is empty.
func (*MapAssertion[K, V]) Equal ¶ added in v1.2.4
func (a *MapAssertion[K, V]) Equal(expect map[K]V, msg ...string) *MapAssertion[K, V]
Equal asserts that the map is equal to the expected map.
func (*MapAssertion[K, V]) HasSameKeys ¶ added in v1.2.4
func (a *MapAssertion[K, V]) HasSameKeys(expect map[K]V, msg ...string) *MapAssertion[K, V]
HasSameKeys asserts that the map has the same keys as the expected map.
func (*MapAssertion[K, V]) HasSameValues ¶ added in v1.2.4
func (a *MapAssertion[K, V]) HasSameValues(expect map[K]V, msg ...string) *MapAssertion[K, V]
HasSameValues asserts that the map has the same values as the expected map.
func (*MapAssertion[K, V]) Length ¶ added in v1.2.4
func (a *MapAssertion[K, V]) Length(length int, msg ...string) *MapAssertion[K, V]
Length asserts that the map has the expected length.
func (*MapAssertion[K, V]) Nil ¶ added in v1.2.4
func (a *MapAssertion[K, V]) Nil(msg ...string) *MapAssertion[K, V]
Nil asserts that the map is nil.
func (*MapAssertion[K, V]) NotContainsKey ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotContainsKey(key K, msg ...string) *MapAssertion[K, V]
NotContainsKey asserts that the map does not contain the expected key.
func (*MapAssertion[K, V]) NotContainsKeys ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotContainsKeys(keys []K, msg ...string) *MapAssertion[K, V]
NotContainsKeys asserts that the map does not contain any of the expected keys.
func (*MapAssertion[K, V]) NotContainsValue ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotContainsValue(value V, msg ...string) *MapAssertion[K, V]
NotContainsValue asserts that the map does not contain the expected value.
func (*MapAssertion[K, V]) NotContainsValues ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotContainsValues(values []V, msg ...string) *MapAssertion[K, V]
NotContainsValues asserts that the map does not contain any of the expected values.
func (*MapAssertion[K, V]) NotEmpty ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotEmpty(msg ...string) *MapAssertion[K, V]
NotEmpty asserts that the map is not empty.
func (*MapAssertion[K, V]) NotEqual ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotEqual(expect map[K]V, msg ...string) *MapAssertion[K, V]
NotEqual asserts that the map is not equal to the expected map.
func (*MapAssertion[K, V]) NotNil ¶ added in v1.2.4
func (a *MapAssertion[K, V]) NotNil(msg ...string) *MapAssertion[K, V]
NotNil asserts that the map is not nil.
func (*MapAssertion[K, V]) SubsetOf ¶ added in v1.2.4
func (a *MapAssertion[K, V]) SubsetOf(expect map[K]V, msg ...string) *MapAssertion[K, V]
SubsetOf asserts that the map is a subset of the expected map.
func (*MapAssertion[K, V]) SupersetOf ¶ added in v1.2.4
func (a *MapAssertion[K, V]) SupersetOf(expect map[K]V, msg ...string) *MapAssertion[K, V]
SupersetOf asserts that the map is a superset of the expected map.
type MockTestingT ¶
type MockTestingT struct {
// contains filtered or unexported fields
}
MockTestingT simulates *testing.T for testing purposes. It records output in a buffer for verification during tests.
func (*MockTestingT) Error ¶
func (m *MockTestingT) Error(args ...any)
Error writes error messages to the internal buffer.
func (*MockTestingT) Fatal ¶
func (m *MockTestingT) Fatal(args ...any)
Fatal writes fatal messages to the internal buffer.
func (*MockTestingT) Helper ¶
func (m *MockTestingT) Helper()
func (*MockTestingT) String ¶
func (m *MockTestingT) String() string
String returns the current content of the buffer.
type NumberAssertion ¶ added in v1.2.4
type NumberAssertion[T Number] struct { AssertionBase // contains filtered or unexported fields }
NumberAssertion encapsulates a number value and a test handler for making assertions on the number.
func ThatNumber ¶ added in v1.2.4
func ThatNumber[T Number](t TestingT, v T, fatalOnFailure bool) *NumberAssertion[T]
ThatNumber returns a NumberAssertion for the given testing object and number value.
func (*NumberAssertion[T]) Between ¶ added in v1.2.4
func (a *NumberAssertion[T]) Between(lower, upper T, msg ...string) *NumberAssertion[T]
Between asserts that the number value is between the lower and upper bounds.
func (*NumberAssertion[T]) Equal ¶ added in v1.2.4
func (a *NumberAssertion[T]) Equal(expect T, msg ...string) *NumberAssertion[T]
Equal asserts that the number value is equal to the expected value.
func (*NumberAssertion[T]) GreaterOrEqual ¶ added in v1.2.4
func (a *NumberAssertion[T]) GreaterOrEqual(expect T, msg ...string) *NumberAssertion[T]
GreaterOrEqual asserts that the number value is greater than or equal to the expected value.
func (*NumberAssertion[T]) GreaterThan ¶ added in v1.2.4
func (a *NumberAssertion[T]) GreaterThan(expect T, msg ...string) *NumberAssertion[T]
GreaterThan asserts that the number value is greater than the expected value.
func (*NumberAssertion[T]) InDelta ¶ added in v1.2.4
func (a *NumberAssertion[T]) InDelta(expect T, delta T, msg ...string) *NumberAssertion[T]
InDelta asserts that the number value is within the delta range of the expected value.
func (*NumberAssertion[T]) IsFinite ¶ added in v1.2.4
func (a *NumberAssertion[T]) IsFinite(msg ...string) *NumberAssertion[T]
IsFinite asserts that the number value is finite.
func (*NumberAssertion[T]) IsInf ¶ added in v1.2.4
func (a *NumberAssertion[T]) IsInf(sign int, msg ...string) *NumberAssertion[T]
IsInf asserts that the number value is infinite.
func (*NumberAssertion[T]) IsNaN ¶ added in v1.2.4
func (a *NumberAssertion[T]) IsNaN(msg ...string) *NumberAssertion[T]
IsNaN asserts that the number value is NaN (Not a Number).
func (*NumberAssertion[T]) LessOrEqual ¶ added in v1.2.4
func (a *NumberAssertion[T]) LessOrEqual(expect T, msg ...string) *NumberAssertion[T]
LessOrEqual asserts that the number value is less than or equal to the expected value.
func (*NumberAssertion[T]) LessThan ¶ added in v1.2.4
func (a *NumberAssertion[T]) LessThan(expect T, msg ...string) *NumberAssertion[T]
LessThan asserts that the number value is less than the expected value.
func (*NumberAssertion[T]) Negative ¶ added in v1.2.4
func (a *NumberAssertion[T]) Negative(msg ...string) *NumberAssertion[T]
Negative asserts that the number value is negative.
func (*NumberAssertion[T]) NotBetween ¶ added in v1.2.4
func (a *NumberAssertion[T]) NotBetween(lower, upper T, msg ...string) *NumberAssertion[T]
NotBetween asserts that the number value is not between the lower and upper bounds.
func (*NumberAssertion[T]) NotEqual ¶ added in v1.2.4
func (a *NumberAssertion[T]) NotEqual(expect T, msg ...string) *NumberAssertion[T]
NotEqual asserts that the number value is not equal to the expected value.
func (*NumberAssertion[T]) NotNegative ¶ added in v1.2.4
func (a *NumberAssertion[T]) NotNegative(msg ...string) *NumberAssertion[T]
NotNegative asserts that the number value is non-negative.
func (*NumberAssertion[T]) NotPositive ¶ added in v1.2.4
func (a *NumberAssertion[T]) NotPositive(msg ...string) *NumberAssertion[T]
NotPositive asserts that the number value is non-positive.
func (*NumberAssertion[T]) NotZero ¶ added in v1.2.4
func (a *NumberAssertion[T]) NotZero(msg ...string) *NumberAssertion[T]
NotZero asserts that the number value is not zero.
func (*NumberAssertion[T]) Positive ¶ added in v1.2.4
func (a *NumberAssertion[T]) Positive(msg ...string) *NumberAssertion[T]
Positive asserts that the number value is positive.
func (*NumberAssertion[T]) Zero ¶ added in v1.2.4
func (a *NumberAssertion[T]) Zero(msg ...string) *NumberAssertion[T]
Zero asserts that the number value is zero.
type SliceAssertion ¶ added in v1.2.4
type SliceAssertion[T comparable] struct { AssertionBase // contains filtered or unexported fields }
SliceAssertion encapsulates a slice value and a test handler for making assertions on the slice.
func ThatSlice ¶ added in v1.2.4
func ThatSlice[T comparable](t TestingT, v []T, fatalOnFailure bool) *SliceAssertion[T]
ThatSlice returns a SliceAssertion for the given testing object and slice value.
func (*SliceAssertion[T]) AllMatches ¶ added in v1.2.4
func (a *SliceAssertion[T]) AllMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
AllMatches asserts that all elements in the slice satisfy the given condition.
func (*SliceAssertion[T]) AllUnique ¶ added in v1.2.4
func (a *SliceAssertion[T]) AllUnique(msg ...string) *SliceAssertion[T]
AllUnique asserts that all elements in the slice are unique.
func (*SliceAssertion[T]) AnyMatches ¶ added in v1.2.4
func (a *SliceAssertion[T]) AnyMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
AnyMatches asserts that at least one element in the slice satisfies the given condition.
func (*SliceAssertion[T]) Contains ¶ added in v1.2.4
func (a *SliceAssertion[T]) Contains(element T, msg ...string) *SliceAssertion[T]
Contains asserts that the slice contains the expected element.
func (*SliceAssertion[T]) ContainsSlice ¶ added in v1.2.4
func (a *SliceAssertion[T]) ContainsSlice(sub []T, msg ...string) *SliceAssertion[T]
ContainsSlice asserts that the slice contains the expected sub-slice.
func (*SliceAssertion[T]) Empty ¶ added in v1.2.4
func (a *SliceAssertion[T]) Empty(msg ...string) *SliceAssertion[T]
Empty asserts that the slice is empty.
func (*SliceAssertion[T]) Equal ¶ added in v1.2.4
func (a *SliceAssertion[T]) Equal(expect []T, msg ...string) *SliceAssertion[T]
Equal asserts that the slice is equal to the expected slice.
func (*SliceAssertion[T]) HasPrefix ¶ added in v1.2.4
func (a *SliceAssertion[T]) HasPrefix(prefix []T, msg ...string) *SliceAssertion[T]
HasPrefix asserts that the slice starts with the specified prefix.
func (*SliceAssertion[T]) HasSuffix ¶ added in v1.2.4
func (a *SliceAssertion[T]) HasSuffix(suffix []T, msg ...string) *SliceAssertion[T]
HasSuffix asserts that the slice ends with the specified suffix.
func (*SliceAssertion[T]) Length ¶ added in v1.2.4
func (a *SliceAssertion[T]) Length(length int, msg ...string) *SliceAssertion[T]
Length asserts that the slice has the expected length.
func (*SliceAssertion[T]) Nil ¶ added in v1.2.4
func (a *SliceAssertion[T]) Nil(msg ...string) *SliceAssertion[T]
Nil asserts that the slice is nil.
func (*SliceAssertion[T]) NoneMatches ¶ added in v1.2.4
func (a *SliceAssertion[T]) NoneMatches(fn func(T) bool, msg ...string) *SliceAssertion[T]
NoneMatches asserts that no element in the slice satisfies the given condition.
func (*SliceAssertion[T]) NotContains ¶ added in v1.2.4
func (a *SliceAssertion[T]) NotContains(element T, msg ...string) *SliceAssertion[T]
NotContains asserts that the slice does not contain the expected element.
func (*SliceAssertion[T]) NotContainsSlice ¶ added in v1.2.4
func (a *SliceAssertion[T]) NotContainsSlice(sub []T, msg ...string) *SliceAssertion[T]
NotContainsSlice asserts that the slice does not contain the expected sub-slice.
func (*SliceAssertion[T]) NotEmpty ¶ added in v1.2.4
func (a *SliceAssertion[T]) NotEmpty(msg ...string) *SliceAssertion[T]
NotEmpty asserts that the slice is not empty.
func (*SliceAssertion[T]) NotEqual ¶ added in v1.2.4
func (a *SliceAssertion[T]) NotEqual(expect []T, msg ...string) *SliceAssertion[T]
NotEqual asserts that the slice is not equal to the expected slice.
func (*SliceAssertion[T]) NotNil ¶ added in v1.2.4
func (a *SliceAssertion[T]) NotNil(msg ...string) *SliceAssertion[T]
NotNil asserts that the slice is not nil.
type StringAssertion ¶ added in v1.2.4
type StringAssertion struct { AssertionBase // contains filtered or unexported fields }
StringAssertion encapsulates a string value and a test handler for making assertions on the string.
func ThatString ¶ added in v1.2.4
func ThatString(t TestingT, v string, fatalOnFailure bool) *StringAssertion
ThatString returns a StringAssertion for the given testing object and string value.
func (*StringAssertion) Blank ¶ added in v1.2.4
func (a *StringAssertion) Blank(msg ...string) *StringAssertion
Blank reports a test failure if the actual string is not blank (i.e., contains non-whitespace characters).
func (*StringAssertion) Contains ¶ added in v1.2.4
func (a *StringAssertion) Contains(substr string, msg ...string) *StringAssertion
Contains fails the test if the actual string does not contain the specified substring.
func (*StringAssertion) Equal ¶ added in v1.2.4
func (a *StringAssertion) Equal(expect string, msg ...string) *StringAssertion
Equal reports a test failure if the actual string is not equal to the expected string.
func (*StringAssertion) EqualFold ¶ added in v1.2.4
func (a *StringAssertion) EqualFold(expect string, msg ...string) *StringAssertion
EqualFold reports a test failure if the actual string and the given string are not equal under Unicode case-folding.
func (*StringAssertion) HasPrefix ¶ added in v1.2.4
func (a *StringAssertion) HasPrefix(prefix string, msg ...string) *StringAssertion
HasPrefix fails the test if the actual string does not start with the specified prefix.
func (*StringAssertion) HasSuffix ¶ added in v1.2.4
func (a *StringAssertion) HasSuffix(suffix string, msg ...string) *StringAssertion
HasSuffix fails the test if the actual string does not end with the specified suffix.
func (*StringAssertion) IsAlpha ¶ added in v1.2.4
func (a *StringAssertion) IsAlpha(msg ...string) *StringAssertion
IsAlpha reports a test failure if the actual string contains any non-alphabetic characters.
func (*StringAssertion) IsAlphaNumeric ¶ added in v1.2.4
func (a *StringAssertion) IsAlphaNumeric(msg ...string) *StringAssertion
IsAlphaNumeric reports a test failure if the actual string contains any non-alphanumeric characters.
func (*StringAssertion) IsBase64 ¶ added in v1.2.4
func (a *StringAssertion) IsBase64(msg ...string) *StringAssertion
IsBase64 reports a test failure if the actual string is not a valid Base64 encoded string.
func (*StringAssertion) IsEmail ¶ added in v1.2.4
func (a *StringAssertion) IsEmail(msg ...string) *StringAssertion
IsEmail reports a test failure if the actual string is not a valid email address.
func (*StringAssertion) IsHex ¶ added in v1.2.4
func (a *StringAssertion) IsHex(msg ...string) *StringAssertion
IsHex reports a test failure if the actual string is not a valid hexadecimal number.
func (*StringAssertion) IsIPv4 ¶ added in v1.2.4
func (a *StringAssertion) IsIPv4(msg ...string) *StringAssertion
IsIPv4 reports a test failure if the actual string is not a valid IPv4 address.
func (*StringAssertion) IsLowerCase ¶ added in v1.2.4
func (a *StringAssertion) IsLowerCase(msg ...string) *StringAssertion
IsLowerCase reports a test failure if the actual string contains any uppercase characters.
func (*StringAssertion) IsNumeric ¶ added in v1.2.4
func (a *StringAssertion) IsNumeric(msg ...string) *StringAssertion
IsNumeric reports a test failure if the actual string contains any non-numeric characters.
func (*StringAssertion) IsURL ¶ added in v1.2.4
func (a *StringAssertion) IsURL(msg ...string) *StringAssertion
IsURL reports a test failure if the actual string is not a valid URL.
func (*StringAssertion) IsUpperCase ¶ added in v1.2.4
func (a *StringAssertion) IsUpperCase(msg ...string) *StringAssertion
IsUpperCase reports a test failure if the actual string contains any lowercase characters.
func (*StringAssertion) JSONEqual ¶ added in v1.2.4
func (a *StringAssertion) JSONEqual(expect string, msg ...string) *StringAssertion
JSONEqual unmarshals both the actual and expected JSON strings into generic interfaces, then reports a test failure if their resulting structures are not deeply equal. If either string is invalid JSON, the test will fail with the unmarshal error.
func (*StringAssertion) Length ¶ added in v1.2.4
func (a *StringAssertion) Length(length int, msg ...string) *StringAssertion
Length reports a test failure if the actual string's length is not equal to the expected length.
func (*StringAssertion) Matches ¶ added in v1.2.4
func (a *StringAssertion) Matches(pattern string, msg ...string) *StringAssertion
Matches reports a test failure if the actual string does not match the given regular expression.
func (*StringAssertion) NotBlank ¶ added in v1.2.4
func (a *StringAssertion) NotBlank(msg ...string) *StringAssertion
NotBlank reports a test failure if the actual string is blank (i.e., empty or contains only whitespace characters).
func (*StringAssertion) NotEqual ¶ added in v1.2.4
func (a *StringAssertion) NotEqual(expect string, msg ...string) *StringAssertion
NotEqual reports a test failure if the actual string is equal to the given string.