assert

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 9 Imported by: 17

Documentation

Index

Constants

View Source
const ColumnUnknown = 0

ColumnUnknown is used when the column associated with a LocationInfo is not available

Variables

This section is empty.

Functions

func AssertImpl

func AssertImpl(text string, cond bool, values any, loc *LocationInfo, hit bool, must_hit bool, expecting bool, assert_type string, options ...string)

func Can_emit added in v0.1.12

func Can_emit() bool

Can_emit returns true if assertions will be processed, and returns false if assertions will be ignored

func FalseIfReached added in v0.1.10

func FalseIfReached(text string, cond bool, values any, options ...string)

FalseIfReached asserts that when this is evaluated the condition will always be false, or that this is never evaluated.

func IsFalse added in v0.1.10

func IsFalse(text string, cond bool, values any, options ...string)

IsFalse asserts that when this is evaluated the condition will always be false, and that this is evaluated at least once.

func IsTrue added in v0.1.10

func IsTrue(text string, cond bool, values any, options ...string)

IsTrue asserts that when this is evaluated the condition will always be true, and that this is evaluated at least once.

func No_emit added in v0.1.12

func No_emit() bool

Can_emit returns true if assertions will be processed, and returns false if assertions will be ignored

func Reachable added in v0.1.10

func Reachable(text string, values any, options ...string)

Reachable asserts that this is evaluated at least once. This assertion will fail if it is not evaluated, and otherwise will pass.

func SometimesFalse added in v0.1.10

func SometimesFalse(text string, cond bool, values any, options ...string)

SometimesFalse asserts that when this is evaluated the condition will sometimes be false, and that this is evaluated at least once.

func SometimesTrue

func SometimesTrue(text string, cond bool, values any, options ...string)

SometimesTrue asserts that when this is evaluated the condition will sometimes be true, and that this is evaluated at least once.

func TrueIfReached added in v0.1.10

func TrueIfReached(text string, cond bool, values any, options ...string)

TrueIfReached asserts that when this is evaluated the condition will always be true, or that this is never evaluated.

func Unreachable added in v0.1.10

func Unreachable(text string, values any, options ...string)

Unreachable asserts that this is never evaluated. This assertion will fail if it is evaluated.

func Version

func Version() string

Version provides the latest version id of the Anithesis SDK for Go

Types

type AssertInfo

type AssertInfo struct {
	Hit        bool           `json:"hit"`
	MustHit    bool           `json:"must_hit"`
	AssertType string         `json:"assert_type"`
	Expecting  bool           `json:"expecting"`
	Category   string         `json:"category"`
	Message    string         `json:"message"`
	Condition  bool           `json:"condition"`
	Id         string         `json:"id"`
	Location   *LocationInfo  `json:"location"`
	Details    map[string]any `json:"details"`
}

type LocationInfo

type LocationInfo struct {
	Classname string `json:"classname"`
	Funcname  string `json:"function"`
	Filename  string `json:"filename"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
}

LocationInfo represents the attributes known at instrumentation time for each Antithesis assertion discovered

func NewLocInfo

func NewLocInfo(classname, funcname, filename string, line int) *LocationInfo

NewLocInfo creates a LocationInfo from values known outside of the current execution context

func NewLocationInfo

func NewLocationInfo(nframes StackFrameOffset) *LocationInfo

NewLocationInfo creates a LocationInfo directly from the current execution context

type StackFrameOffset

type StackFrameOffset int

StackFrameOffset indicates how many frames to go up in the call stack to find the filename/location/line info. As this work is always done in NewLocationInfo(), the offset is specified from the perspective of NewLocationInfo

const (
	OffsetNewLocationInfo StackFrameOffset = iota
	OffsetHere
	OffsetAPICaller
	OffsetAPICallersCaller
)

Order is important here since iota is being used

Jump to

Keyboard shortcuts

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