be_math

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 9 Imported by: 0

README

be_math

-- import "github.com/expectto/be/be_math"

Package be_math provides Be matchers for mathematical operations

Usage

func Approx
func Approx(compareTo, threshold any) types.BeMatcher

Approx succeeds if actual is numerically approximately equal to the passed-in value within the specified threshold.

func ApproxZero
func ApproxZero() types.BeMatcher

ApproxZero succeeds if actual is numerically approximately equal to zero Any type of int/float will work for comparison.

func DivisibleBy
func DivisibleBy(divisor any) types.BeMatcher

DivisibleBy succeeds if actual is numerically divisible by the passed-in value.

func Even
func Even() types.BeMatcher

Even succeeds if actual is an even numeric value.

func GreaterThan
func GreaterThan(arg any) types.BeMatcher

GreaterThan succeeds if actual is numerically greater than the passed-in value.

func GreaterThanEqual
func GreaterThanEqual(arg any) types.BeMatcher

GreaterThanEqual succeeds if actual is numerically greater than or equal to the passed-in value.

func Gt
func Gt(arg any) types.BeMatcher

Gt is an alias for GreaterThan, succeeding if actual is numerically greater than the passed-in value.

func Gte
func Gte(arg any) types.BeMatcher

Gte is an alias for GreaterThanEqual, succeeding if actual is numerically greater than or equal to the passed-in value.

func InRange
func InRange(from any, fromInclusive bool, until any, untilInclusive bool) types.BeMatcher

InRange succeeds if actual is numerically within the specified range. The range is defined by the 'from' and 'until' values, and inclusivity is determined by the 'fromInclusive' and 'untilInclusive' flags.

func Integral
func Integral() types.BeMatcher

Integral succeeds if actual is an integral float, meaning it has zero decimal places. This matcher checks if the numeric value has no fractional component.

func LessThan
func LessThan(arg any) types.BeMatcher

LessThan succeeds if actual is numerically less than the passed-in value.

func LessThanEqual
func LessThanEqual(arg any) types.BeMatcher

LessThanEqual succeeds if actual is numerically less than or equal to the passed-in value.

func Lt
func Lt(arg any) types.BeMatcher

Lt is an alias for LessThan, succeeding if actual is numerically less than the passed-in value.

func Lte
func Lte(arg any) types.BeMatcher

Lte is an alias for LessThanEqual, succeeding if actual is numerically less than or equal to the passed-in value.

func Negative
func Negative() types.BeMatcher

Negative succeeds if actual is a negative numeric value.

func Odd
func Odd() types.BeMatcher

Odd succeeds if actual is an odd numeric value.

func Positive
func Positive() types.BeMatcher

Positive succeeds if actual is a positive numeric value.

func Zero
func Zero() types.BeMatcher

Zero succeeds if actual is numerically equal to zero. Any type of int/float will work for comparison.

Documentation

Overview

Package be_math provides Be matchers for mathematical operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Approx

func Approx(compareTo, threshold any) types.BeMatcher

Approx succeeds if actual is numerically approximately equal to the passed-in value within the specified threshold.

func ApproxZero added in v0.2.0

func ApproxZero() types.BeMatcher

ApproxZero succeeds if actual is numerically approximately equal to zero Any type of int/float will work for comparison.

func DivisibleBy

func DivisibleBy(divisor any) types.BeMatcher

DivisibleBy succeeds if actual is numerically divisible by the passed-in value.

func Even

func Even() types.BeMatcher

Even succeeds if actual is an even numeric value.

func GreaterThan

func GreaterThan(arg any) types.BeMatcher

GreaterThan succeeds if actual is numerically greater than the passed-in value.

func GreaterThanEqual

func GreaterThanEqual(arg any) types.BeMatcher

GreaterThanEqual succeeds if actual is numerically greater than or equal to the passed-in value.

func Gt

func Gt(arg any) types.BeMatcher

Gt is an alias for GreaterThan, succeeding if actual is numerically greater than the passed-in value.

func Gte

func Gte(arg any) types.BeMatcher

Gte is an alias for GreaterThanEqual, succeeding if actual is numerically greater than or equal to the passed-in value.

func InRange

func InRange(from any, fromInclusive bool, until any, untilInclusive bool) types.BeMatcher

InRange succeeds if actual is numerically within the specified range. The range is defined by the 'from' and 'until' values, and inclusivity is determined by the 'fromInclusive' and 'untilInclusive' flags.

func Integral

func Integral() types.BeMatcher

Integral succeeds if actual is an integral float, meaning it has zero decimal places. This matcher checks if the numeric value has no fractional component.

func LessThan

func LessThan(arg any) types.BeMatcher

LessThan succeeds if actual is numerically less than the passed-in value.

func LessThanEqual

func LessThanEqual(arg any) types.BeMatcher

LessThanEqual succeeds if actual is numerically less than or equal to the passed-in value.

func Lt

func Lt(arg any) types.BeMatcher

Lt is an alias for LessThan, succeeding if actual is numerically less than the passed-in value.

func Lte

func Lte(arg any) types.BeMatcher

Lte is an alias for LessThanEqual, succeeding if actual is numerically less than or equal to the passed-in value.

func Negative

func Negative() types.BeMatcher

Negative succeeds if actual is a negative numeric value.

func Odd

func Odd() types.BeMatcher

Odd succeeds if actual is an odd numeric value.

func Positive

func Positive() types.BeMatcher

Positive succeeds if actual is a positive numeric value.

func Zero

func Zero() types.BeMatcher

Zero succeeds if actual is numerically equal to zero. Any type of int/float will work for comparison.

Types

This section is empty.

Jump to

Keyboard shortcuts

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