Documentation
¶
Overview ¶
Package tst contains unit testing functions and TestCase structs
Index ¶
- func All[T any](t *testing.T, pairs [][2]T, name string, assert assertFn[T])
- func AllActionPost[T HasPostTest](t *testing.T, testCases []T, name string, actionFn func(T))
- func AllCompare1[T, R any](t *testing.T, testCases []T, name string, testFn func(T) (R, R), ...)
- func AllP1W1[I, R any](t *testing.T, testCases []P1W1[I, R], name string, testFn func(I) R, ...)
- func AllP1W2[I, R1, R2 any](t *testing.T, testCases []P1W2[I, R1, R2], name string, ...)
- func AllP2W1[I1, I2, R any](t *testing.T, testCases []P2W1[I1, I2, R], name string, testFn func(I1, I2) R, ...)
- func AllP2W2[I1, I2, R1, R2 any](t *testing.T, testCases []P2W2[I1, I2, R1, R2], name string, ...)
- func AllP2W2Pre[I1, I2, R1, R2 any](t *testing.T, testCases []P2W2Pre[I1, I2, R1, R2], name string, ...)
- func AllP2W3Pre[I1, I2, R1, R2, R3 any](t *testing.T, testCases []P2W3Pre[I1, I2, R1, R2, R3], name string, ...)
- func AllP2W4Pre[I1, I2, R1, R2, R3, R4 any](t *testing.T, testCases []P2W4Pre[I1, I2, R1, R2, R3, R4], name string, ...)
- func AllP3W1[I1, I2, I3, R any](t *testing.T, testCases []P3W1[I1, I2, I3, R], name string, ...)
- func AllP3W1Post[I1, I2, I3, R any](t *testing.T, testCases []P3W1Post[I1, I2, I3, R], name string, ...)
- func AllP3W2[I1, I2, I3, R1, R2 any](t *testing.T, testCases []P3W2[I1, I2, I3, R1, R2], name string, ...)
- func AllP3W2Pre[I1, I2, I3, R1, R2 any](t *testing.T, testCases []P3W2Pre[I1, I2, I3, R1, R2], name string, ...)
- func AssertDeepEqual(t *testing.T, name string, a, b any)
- func AssertDeepEqualAnd(t *testing.T, name string, a, b any, flag1, flag2 bool)
- func AssertDeepEqualError(t *testing.T, name string, a, b any, err error, notNil bool)
- func AssertEqual[T comparable](t *testing.T, name string, a, b T)
- func AssertEqual2[T1, T2 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2)
- func AssertEqual3[T1, T2, T3 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2, a3, b3 T3)
- func AssertEqual4[T1, T2, T3, T4 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2, a3, b3 T3, a4, b4 T4)
- func AssertEqualAnd[T comparable](t *testing.T, name string, a, b T, flag1, flag2 bool)
- func AssertEqualAny(t *testing.T, name string, a, b any)
- func AssertEqualAnyAnd(t *testing.T, name string, a, b any, flag1, flag2 bool)
- func AssertEqualAnyError(t *testing.T, name string, a, b any, err error, notNil bool)
- func AssertEqualError[T comparable](t *testing.T, name string, a, b T, err error, notNil bool)
- func AssertError(t *testing.T, name string, err error)
- func AssertFalse(t *testing.T, name string, condition bool)
- func AssertListEqual[S ~[]T, T comparable](t *testing.T, name string, a, b S)
- func AssertListEqualAnd[S ~[]T, T comparable](t *testing.T, name string, a, b S, flag1, flag2 bool)
- func AssertListEqualError[S ~[]T, T comparable](t *testing.T, name string, a, b S, err error, notNil bool)
- func AssertListMixedEqual[S ~[]T, T comparable](t *testing.T, name string, a, b S)
- func AssertMapEqual[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2)
- func AssertMapEqualAnd[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2, flag1, flag2 bool)
- func AssertMapEqualError[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2, err error, notNil bool)
- func AssertNoError(t *testing.T, name string, err error)
- func AssertPanic(t *testing.T, name string)
- func AssertTrue(t *testing.T, name string, condition bool)
- func Convert[T, V any](items []T, convert func(T) V) []V
- type Conn
- func (c *Conn[T]) Begin() (*Tx, error)
- func (c *Conn[T]) Exec(query string, args ...any) (sql.Result, error)
- func (c *Conn[T]) Items() []T
- func (c *Conn[T]) PrepExec(execFn func([]T) ([]T, error), result sql.Result) func()
- func (c *Conn[T]) PrepExecReset(execFn func([]T) ([]T, error), result sql.Result, items ...T) func()
- func (c *Conn[T]) PrepGroup(testFn func(T) bool, groupFn func([]T) [][]any) func()
- func (c *Conn[T]) PrepGroupErr(testFn func(T) bool, groupFn func([]T) [][]any, rowsErr error) func()
- func (c *Conn[T]) PrepOne(testFn func(T) bool, rowFn func(T) []any) func()
- func (c *Conn[T]) PrepRow(testFn func(T) bool, rowFn func([]T) ([]any, error)) func()
- func (c *Conn[T]) PrepRows(testFn func(T) bool, rowsFn func(T) []any) func()
- func (c *Conn[T]) PrepRowsErr(testFn func(T) bool, rowsFn func(T) []any, rowsErr error) func()
- func (c *Conn[T]) PrepSortOne(testFn func(T) bool, rowFn func(T) []any, sortFn func(T, T) int) func()
- func (c *Conn[T]) PrepSortRows(testFn func(T) bool, rowsFn func(T) []any, sortFn func(T, T) int, limit int) func()
- func (c *Conn[T]) Query(query string, args ...any) (*Rows, error)
- func (c *Conn[T]) QueryRow(query string, args ...any) *Row
- func (c *Conn[T]) Reset(items ...T)
- func (c *Conn[T]) SetError(err error)
- type HasPostTest
- type P1W1
- type P1W2
- type P2W1
- type P2W2
- type P2W2Pre
- type P2W3Pre
- type P2W4Pre
- type P3W1
- type P3W1Post
- type P3W2
- type P3W2Pre
- type Result
- type Row
- type Rows
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllActionPost ¶
func AllActionPost[T HasPostTest](t *testing.T, testCases []T, name string, actionFn func(T))
AllActionPost performs the action for all generic test cases and checks the post-test
func AllCompare1 ¶
func AllCompare1[T, R any](t *testing.T, testCases []T, name string, testFn func(T) (R, R), assert assertFn[R])
AllCompare1 tests 1 pair of [actual, want] from the given generic test cases
func AllP1W1 ¶
func AllP1W1[I, R any](t *testing.T, testCases []P1W1[I, R], name string, testFn func(I) R, assert assertFn[R])
AllP1W1 tests all P1W1 test cases
func AllP1W2 ¶
func AllP1W2[I, R1, R2 any](t *testing.T, testCases []P1W2[I, R1, R2], name string, testFn func(I) (R1, R2), assert1 assertFn[R1], assert2 assertFn[R2])
AllP1W2 tests all P1W2 test cases
func AllP2W1 ¶
func AllP2W1[I1, I2, R any](t *testing.T, testCases []P2W1[I1, I2, R], name string, testFn func(I1, I2) R, assert assertFn[R])
AllP2W1 tests all P2W1 test cases
func AllP2W2 ¶
func AllP2W2[I1, I2, R1, R2 any](t *testing.T, testCases []P2W2[I1, I2, R1, R2], name string, testFn func(I1, I2) (R1, R2), assert1 assertFn[R1], assert2 assertFn[R2])
AllP2W2 tests all P2W2 test cases
func AllP2W2Pre ¶
func AllP2W2Pre[I1, I2, R1, R2 any](t *testing.T, testCases []P2W2Pre[I1, I2, R1, R2], name string, testFn func(I1, I2) (R1, R2), assert1 assertFn[R1], assert2 assertFn[R2])
AllP2W2Pre tests all P2W2Pre test cases
func AllP2W3Pre ¶
func AllP2W3Pre[I1, I2, R1, R2, R3 any](t *testing.T, testCases []P2W3Pre[I1, I2, R1, R2, R3], name string, testFn func(I1, I2) (R1, R2, R3), assert1 assertFn[R1], assert2 assertFn[R2], assert3 assertFn[R3])
AllP2W3Pre tests all P2W3Pre test cases
func AllP2W4Pre ¶
func AllP2W4Pre[I1, I2, R1, R2, R3, R4 any](t *testing.T, testCases []P2W4Pre[I1, I2, R1, R2, R3, R4], name string, testFn func(I1, I2) (R1, R2, R3, R4), assert1 assertFn[R1], assert2 assertFn[R2], assert3 assertFn[R3], assert4 assertFn[R4])
AllP2W4Pre tests all P2W4Pre test cases
func AllP3W1 ¶
func AllP3W1[I1, I2, I3, R any](t *testing.T, testCases []P3W1[I1, I2, I3, R], name string, testFn func(I1, I2, I3) R, assert assertFn[R])
AllP3W1 tests all P3W1 test cases
func AllP3W1Post ¶
func AllP3W1Post[I1, I2, I3, R any](t *testing.T, testCases []P3W1Post[I1, I2, I3, R], name string, testFn func(I1, I2, I3) R, assert assertFn[R])
AllP3W1Post tests all P3W1Post test cases and checks the post-test function
func AllP3W2 ¶
func AllP3W2[I1, I2, I3, R1, R2 any](t *testing.T, testCases []P3W2[I1, I2, I3, R1, R2], name string, testFn func(I1, I2, I3) (R1, R2), assert1 assertFn[R1], assert2 assertFn[R2])
AllP3W2 tests all P3W2 test cases
func AllP3W2Pre ¶
func AllP3W2Pre[I1, I2, I3, R1, R2 any](t *testing.T, testCases []P3W2Pre[I1, I2, I3, R1, R2], name string, testFn func(I1, I2, I3) (R1, R2), assert1 assertFn[R1], assert2 assertFn[R2])
AllP3W2Pre tests all P3W2Pre test cases
func AssertDeepEqual ¶
AssertDeepEqual asserts that the two `any` items are deeply equal
func AssertDeepEqualAnd ¶
AssertDeepEqualAnd asserts that the two `any` items are deeply equal and the boolean flags are equal
func AssertDeepEqualError ¶
AssertDeepEqualError asserts that the two `any` items are deeply equal and the error follows notNil flag
func AssertEqual ¶
func AssertEqual[T comparable](t *testing.T, name string, a, b T)
AssertEqual asserts that the two given values are equal
func AssertEqual2 ¶
func AssertEqual2[T1, T2 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2)
AssertEqual2 asserts that the two pairs of values are all equal
func AssertEqual3 ¶
func AssertEqual3[T1, T2, T3 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2, a3, b3 T3)
AssertEqual3 asserts that the three pairs of values are all equal
func AssertEqual4 ¶
func AssertEqual4[T1, T2, T3, T4 comparable](t *testing.T, name string, a1, b1 T1, a2, b2 T2, a3, b3 T3, a4, b4 T4)
AssertEqual4 asserts that the four pairs of values are all equal
func AssertEqualAnd ¶
func AssertEqualAnd[T comparable](t *testing.T, name string, a, b T, flag1, flag2 bool)
AssertEqualAnd asserts that the two given values are equal and the boolean flags are equal
func AssertEqualAny ¶
AssertEqualAny checks if two `any` items are equal
func AssertEqualAnyAnd ¶
AssertEqualAnyAnd checks if two `any` items are equal and the boolean flags are equal
func AssertEqualAnyError ¶
AssertEqualAnyError checks if two `any` items are equal and the error follows notNil flag
func AssertEqualError ¶
AssertEqualError asserts that the two given values are equal and the error follows notNil flag
func AssertError ¶
AssertError asserts that the given error is not nil
func AssertFalse ¶
AssertFalse asserts that the given condition is false
func AssertListEqual ¶
func AssertListEqual[S ~[]T, T comparable](t *testing.T, name string, a, b S)
AssertListEqual asserts that the two given lists are equal
func AssertListEqualAnd ¶
func AssertListEqualAnd[S ~[]T, T comparable](t *testing.T, name string, a, b S, flag1, flag2 bool)
AssertListEqualAnd asserts that the two given lists are equal and the boolean flags are equal
func AssertListEqualError ¶
func AssertListEqualError[S ~[]T, T comparable](t *testing.T, name string, a, b S, err error, notNil bool)
AssertListEqualError asserts that the two given lists are equal and the error follows notNil flag
func AssertListMixedEqual ¶
func AssertListMixedEqual[S ~[]T, T comparable](t *testing.T, name string, a, b S)
AssertListMixedEqual asserts that the two given lists are equal, with pointers and nil checks handled
func AssertMapEqual ¶
func AssertMapEqual[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2)
AssertMapEqual asserts that the two given maps are equal
func AssertMapEqualAnd ¶
func AssertMapEqualAnd[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2, flag1, flag2 bool)
AssertMapEqualAnd asserts that the two given maps are equal and the boolean flags are equal
func AssertMapEqualError ¶
func AssertMapEqualError[M1, M2 ~map[K]V, K, V comparable](t *testing.T, name string, a M1, b M2, err error, notNil bool)
AssertMapEqualError asserts that the two given maps are equal and the error follows notNil flag
func AssertNoError ¶
AssertNoError asserts that the given error is nil
func AssertPanic ¶
AssertPanic asserts that the end of the function will panic Usage: defer AssertPanic(t, name)
func AssertTrue ¶
AssertTrue asserts that the given condition is true
Types ¶
type Conn ¶
type Conn[T any] struct { // contains filtered or unexported fields }
func (*Conn[T]) PrepExecReset ¶
func (*Conn[T]) PrepGroupErr ¶
func (*Conn[T]) PrepRowsErr ¶
func (*Conn[T]) PrepSortOne ¶
func (*Conn[T]) PrepSortRows ¶
type HasPostTest ¶
type HasPostTest interface {
PostTest() bool
}
type P1W2 ¶
type P1W2[I, R1, R2 any] struct { P1 I W1 R1 W2 R2 }
P1W2 Test case with 1 input, 2 outputs
type P2W1 ¶
type P2W1[I1, I2, R any] struct { P1 I1 P2 I2 W1 R }
P2W1 Test case with 2 inputs, 1 output
type P2W2 ¶
type P2W2[I1, I2, R1, R2 any] struct { P1 I1 P2 I2 W1 R1 W2 R2 }
P2W2 Test case with 2 inputs, 2 outputs
type P2W2Pre ¶
type P2W2Pre[I1, I2, R1, R2 any] struct { Prep func() P1 I1 P2 I2 W1 R1 W2 R2 }
P2W2Pre Test Case with 2 inputs, 2 outputs, and a `prepare` step
type P2W3Pre ¶
type P2W3Pre[I1, I2, R1, R2, R3 any] struct { Prep func() P1 I1 P2 I2 W1 R1 W2 R2 W3 R3 }
P2W3Pre Test Case with 2 inputs, 3 outputs, and a `prepare` step
type P2W4Pre ¶
type P2W4Pre[I1, I2, R1, R2, R3, R4 any] struct { Prep func() P1 I1 P2 I2 W1 R1 W2 R2 W3 R3 W4 R4 }
P2W4Pre Test Case with 2 inputs, 4 outputs, and a `prepare` step
type P3W1 ¶
type P3W1[I1, I2, I3, R any] struct { P1 I1 P2 I2 P3 I3 W1 R }
P3W1 Test case with 3 inputs, 1 output
type P3W2 ¶
type P3W2[I1, I2, I3, R1, R2 any] struct { P1 I1 P2 I2 P3 I3 W1 R1 W2 R2 }
P3W2 Test case with 3 inputs, 2 outputs
type P3W2Pre ¶
type P3W2Pre[I1, I2, I3, R1, R2 any] struct { Prep func() P1 I1 P2 I2 P3 I3 W1 R1 W2 R2 }
P3W2Pre Test case with 3 inputs, 2 outputs, and a `prepare` step
type Result ¶
type Result struct {
// contains filtered or unexported fields
}