Documentation
¶
Overview ¶
This package offers some helper functions to make easier to write unit tests with iterators and maps.
Index ¶
- func AssertErrIs(t TestingT, err error, target error, msg string)
- func AssertErrNil(t TestingT, err error, msg string)
- func AssertErrNotNil(t TestingT, err error, msg string)
- func ValidateIterator[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], isOrdered bool, ...) bool
- func ValidateIteratorBackward[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], shouldBeInvalidAtEnd bool, ...) bool
- func ValidateIteratorForward[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], isOrdered bool, ...) bool
- type KeyValue
- type TestingErrorsMock
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrNil ¶
func AssertErrNotNil ¶
func ValidateIterator ¶
func ValidateIterator[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], isOrdered bool, expResults []KeyValue[K, V]) bool
func ValidateIteratorBackward ¶
func ValidateIteratorBackward[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], shouldBeInvalidAtEnd bool, expResults []KeyValue[K, V]) bool
func ValidateIteratorForward ¶
func ValidateIteratorForward[K comparable, V comparable](t TestingT, it omap.OMapIterator[K, V], isOrdered bool, expResults []KeyValue[K, V]) bool
Types ¶
type KeyValue ¶
type KeyValue[K comparable, V comparable] struct { Key K Value V }
func JsonToKV ¶
func JsonToKV[K comparable, V comparable](in string) []KeyValue[K, V]
Convert a JSON array in form of `[[key1, val1], [key2, val2], ...]` to []KeyValue[K, V]. Returns nil in case of error, since validator functions will treat this specifically. One can use JsonToKVErr to debug the actual error. Notice: this function is intentionally designed to be short to build a []KeyValue from a hard-coded constant, so it is not well designed to be safe nor fast.
func JsonToKVErr ¶
func JsonToKVErr[K comparable, V comparable](in string) ([]KeyValue[K, V], error)
func SlicesToKeyValue ¶
func SlicesToKeyValue[K comparable, V comparable](keys []K, values []V) []KeyValue[K, V]
type TestingErrorsMock ¶
type TestingErrorsMock struct {
// contains filtered or unexported fields
}
func (*TestingErrorsMock) Errorf ¶
func (tm *TestingErrorsMock) Errorf(format string, args ...any)
func (*TestingErrorsMock) Helper ¶
func (tm *TestingErrorsMock) Helper()
func (*TestingErrorsMock) Reset ¶
func (tm *TestingErrorsMock) Reset()
Click to show internal directories.
Click to hide internal directories.