testcases

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package testcases provides test cases for testing nil, equal, empty and zero values.

Index

Constants

View Source
const (
	TCBoolA       bool       = true
	TCBoolB       bool       = true
	TCBoolC       bool       = false
	TCStringA     string     = "abc"
	TCStringB     string     = "abc"
	TCStringC     string     = "cba"
	TCIntA        int        = -123
	TCIntB        int        = -123
	TCIntC        int        = -321
	TCInt8A       int8       = -8
	TCInt8B       int8       = -8
	TCInt8C       int8       = -13
	TCInt16A      int16      = -16
	TCInt16B      int16      = -16
	TCInt16C      int16      = -61
	TCInt32A      int32      = -32
	TCInt32B      int32      = -32
	TCInt32C      int32      = -23
	TCInt64A      int64      = -64
	TCInt64B      int64      = -64
	TCInt64C      int64      = -46
	TCUintA       uint       = 123
	TCUintB       uint       = 123
	TCUintC       uint       = 321
	TCUint8A      uint8      = 8
	TCUint8B      uint8      = 8
	TCUint8C      uint8      = 13
	TCUint16A     uint16     = 16
	TCUint16B     uint16     = 16
	TCUint16C     uint16     = 61
	TCUint32A     uint32     = 32
	TCUint32B     uint32     = 32
	TCUint32C     uint32     = 23
	TCUint64A     uint64     = 64
	TCUint64B     uint64     = 64
	TCUint64C     uint64     = 46
	TCUintptrA    uintptr    = 42
	TCUintptrB    uintptr    = 42
	TCUintptrC    uintptr    = 24
	TCFloat32A    float32    = 32.0
	TCFloat32B    float32    = 32.0
	TCFloat32C    float32    = 23.0
	TCFloat64A    float64    = 64.0
	TCFloat64B    float64    = 64.0
	TCFloat64C    float64    = 46.0
	TCComplex64A  complex64  = 6i + 4
	TCComplex64B  complex64  = 6i + 4
	TCComplex64C  complex64  = 4i + 6
	TCComplex128A complex128 = 12i + 8
	TCComplex128B complex128 = 12i + 8
	TCComplex128C complex128 = 8i + 12

	CBoolA       = true
	CBoolB       = true
	CBoolC       = false
	CStringA     = "abc"
	CStringB     = "abc"
	CStringC     = "xyz"
	CIntA        = 123
	CIntB        = 123
	CIntC        = 321
	CFloatA      = 1.23
	CFloatB      = 1.23
	CFloatC      = 3.21
	CComplex64A  = 6i + 4
	CComplex64B  = 6i + 4
	CComplex64C  = 4i + 6
	CComplex128A = 12i + 8
	CComplex128B = 12i + 8
	CComplex128C = 8i + 12
)

Variables

WAW represents Europe/Warsaw timezone.

Functions

func TFuncA

func TFuncA()

func TFuncB

func TFuncB()

Types

type EqualCase

type EqualCase struct {
	Desc     string // The case description.
	Val0     any    // The first value.
	Val1     any    // The second value.
	AreEqual bool   // Are the values equal?
}

EqualCase represents two values and if they are considered equal.

func EqualCases

func EqualCases() []EqualCase

EqualCases returns cases to test equality.

func EqualConstants

func EqualConstants() []EqualCase

EqualConstants returns cases to test equality for typed constants.

func EqualPrimitives

func EqualPrimitives() []EqualCase

EqualPrimitives returns cases to test equality for primitive types.

type TA

type TA struct {
	Int int
	Str string
	Tim time.Time
	Dur time.Duration
	Loc *time.Location
	TAp *TA
	// contains filtered or unexported fields
}

type TB

type TB struct {
	TA     // Embedded by value.
	TAv TA // Non-pointer type.
}

type TC

type TC struct {
	TD
	Int int
}

type TD

type TD string

type TInt

type TInt struct{ V int }

func NewTInt

func NewTInt(v int) (*TInt, error)

type TIntStr

type TIntStr struct {
	Int int
	Str string
}

type TIntType

type TIntType int

type TItf

type TItf interface{ AAA() string }

TItf is an interface used in tests.

type TLoc

type TLoc struct{ Loc *time.Location }

type TNested

type TNested struct {
	SInt    []int
	STA     []TA
	STAp    []*TA
	MStrInt map[string]int
	MStrTyp map[string]TA
	MIntTyp map[int]TA
}

type TPrv

type TPrv struct {
	Pub int
	// contains filtered or unexported fields
}

func NewTPrv

func NewTPrv() TPrv

func (TPrv) SetAInt

func (prv TPrv) SetAInt(a [2]int) TPrv

func (TPrv) SetCh

func (prv TPrv) SetCh(ch chan int) TPrv

func (TPrv) SetFn

func (prv TPrv) SetFn(fn func() int) TPrv

func (TPrv) SetInt

func (prv TPrv) SetInt(v int) TPrv

func (TPrv) SetMapII

func (prv TPrv) SetMapII(m map[int]int) TPrv

func (TPrv) SetPtr

func (prv TPrv) SetPtr(ptr *TVal) TPrv

func (TPrv) SetSInt

func (prv TPrv) SetSInt(s []int) TPrv

func (TPrv) SetTim

func (prv TPrv) SetTim(tim time.Time) TPrv

type TPtr

type TPtr struct{ Val string } // nolint: errname

func (*TPtr) AAA

func (typ *TPtr) AAA() string

func (*TPtr) Error

func (typ *TPtr) Error() string

func (*TPtr) Identity

func (typ *TPtr) Identity(val *string) *string

func (*TPtr) Variadic

func (typ *TPtr) Variadic(str string, i ...int) string

func (*TPtr) Wrap

func (typ *TPtr) Wrap(a, b string) string

type TRec

type TRec struct {
	Int int
	Rec *TRec // Recursive.
}

type TStrType

type TStrType string

type TTim

type TTim struct{ Tim time.Time }

type TVal

type TVal struct{ Val string } // nolint: errname

func (TVal) AAA

func (typ TVal) AAA() string

func (TVal) Error

func (typ TVal) Error() string

type ZENValue

type ZENValue struct {
	Desc    string // The value description.
	Val     any    // The value.
	IsZero  bool   // Is Val considered zero value.
	IsEmpty bool   // Is Val considered empty value.
	IsNil   bool   // Is Val considered nil value.
}

ZENValue represents a value and if it's considered zero, empty or nil value.

func ZENValues

func ZENValues() []ZENValue

ZENValues returns cases for zero, empty and nil values.

Jump to

Keyboard shortcuts

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