floats

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package floats provides members to register and test float Mock objects. It is intended to be used in concert with "*testing.T" functions, and the "go test" command, which automates execution of any function of the form:

"func TestXxx(*testing.T)" functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fluent

func Fluent[T constraints.Float](t *testing.T) fluent.IFluent[T, IComparable[T]]

Fluent[T constraints.Float] returns an "*fluent.Fluent[T]" representing a Mock object used on further test cases. The generic type parameter represents any testable float32 or float64 subject.

Types

type Additional

type Additional[T constraints.Float] struct {
	*Comparable[T]
}

Additional[T constraints.Float] is a type returned by some easy-to-use testing methods, providing basic additive test chaining with "And()".

func (*Additional[T]) And

func (s *Additional[T]) And() IComparable[T]

And extends the testing operation againts the Mock subject, returning an "*Comparable[T]" object which provides a set of easy-to-use methods to test the subject in an additive maner.

The "And()" method works as an additive connector between test methods from "IComparable[T]", allowing execution of chained testing methods.

type Comparable

type Comparable[T constraints.Float] struct {
	*Testable[T]
}

Comparable[T constraints.Float] is a type returned by calling "fluentObj.It(0.9999).Should()", encapsulating a "*Testable[T]" object for further testing, and providing all the floats package's easy-to-use set of methods with signatures declared at the "floats.IComparable[T constraints.Float]" interface.

NOTE: The "It()" method in the example accepts any float number as per constraint "constraints.Float".

func (*Comparable[T]) Be

func (s *Comparable[T]) Be(value T)

Be asserts a Mock object as having the constrained-typed value as per "value T" argument.

func (*Comparable[T]) BeGreaterThan

func (s *Comparable[T]) BeGreaterThan(value T) fluent.IAdditional[T, IComparable[T]]

BeGreaterThan asserts a Mock object as having a value greater than the "value T" argument.

func (*Comparable[T]) BeGreaterThanOrEqualTo

func (s *Comparable[T]) BeGreaterThanOrEqualTo(value T) fluent.IAdditional[T, IComparable[T]]

BeGreaterThanOrEqualTo asserts a Mock object as having a value greater than, or equal to the "value T" argument.

func (*Comparable[T]) BeLowerThan

func (s *Comparable[T]) BeLowerThan(value T) fluent.IAdditional[T, IComparable[T]]

BeLowerThan asserts a Mock object as having a value lower than the "value T" argument.

func (*Comparable[T]) BeLowerThanOrEqualTo

func (s *Comparable[T]) BeLowerThanOrEqualTo(value T) fluent.IAdditional[T, IComparable[T]]

BeLowerThanOrEqualTo asserts a Mock object as having a value lower than, or equal to the "value T" argument.

func (*Comparable[T]) BeNegative

func (s *Comparable[T]) BeNegative() fluent.IAdditional[T, IComparable[T]]

BeNegative asserts a Mock object as having a negative value "<0.0".

func (*Comparable[T]) BePositive

func (s *Comparable[T]) BePositive() fluent.IAdditional[T, IComparable[T]]

BePositive asserts a Mock object as having a positive value ">=0.0".

func (*Comparable[T]) BeZero

func (s *Comparable[T]) BeZero()

BeZero asserts a Mock object as having value of "0.0".

func (*Comparable[T]) NotBe

func (s *Comparable[T]) NotBe(value T) fluent.IAdditional[T, IComparable[T]]

NotBe asserts a Mock object as NOT having the same value as per "value T" argument.

func (*Comparable[T]) NotBeNegative

func (s *Comparable[T]) NotBeNegative() fluent.IAdditional[T, IComparable[T]]

NotBeNegative asserts a Mock object as NOT having a negative value.

func (*Comparable[T]) NotBePositive

func (s *Comparable[T]) NotBePositive() fluent.IAdditional[T, IComparable[T]]

NotBePositive asserts a Mock object as NOT having a positive value.

func (*Comparable[T]) NotBeZero

func (s *Comparable[T]) NotBeZero() fluent.IAdditional[T, IComparable[T]]

NotBeZero asserts a Mock object as NOT having value of "0.0".

type FluentT

type FluentT[T constraints.Float] struct {
	// contains filtered or unexported fields
}

FluentT[T constraints.Float] is a type returned by calling "floats.Fluent[constraints.Float](t)" for enabling easy-to-use testing methods.

It carries the "*testing.T" object to be further used in the methods chain.

func (*FluentT[T]) It

func (s *FluentT[T]) It(subject T) fluent.ISubject[T, IComparable[T]]

It receives a subject object of generic type "T", a constraint of Float for further testing, and returns an "Subject[T]" object.

type IComparable

type IComparable[T constraints.Float] interface {
	fluent.IComparable[T]
	Be(value T) // If comparable to be a Value, no other comparison is required
	BeZero()    // If comparable to Zero, no other comparison is required
	BeNegative() fluent.IAdditional[T, IComparable[T]]
	BePositive() fluent.IAdditional[T, IComparable[T]]
	// BeOfType(t types.Type)
	NotBe(value T) fluent.IAdditional[T, IComparable[T]]
	NotBeZero() fluent.IAdditional[T, IComparable[T]]
	NotBeNegative() fluent.IAdditional[T, IComparable[T]]
	NotBePositive() fluent.IAdditional[T, IComparable[T]]
	BeLowerThan(value T) fluent.IAdditional[T, IComparable[T]]
	BeLowerThanOrEqualTo(value T) fluent.IAdditional[T, IComparable[T]]
	BeGreaterThan(value T) fluent.IAdditional[T, IComparable[T]]
	BeGreaterThanOrEqualTo(value T) fluent.IAdditional[T, IComparable[T]]
}

IComparable[T constraints.Float] interface for the floats package. Following the Fluent-Interface design pattern to provide chained testing methods.

type Subject

type Subject[T constraints.Float] struct {
	*Testable[T]
}

Subject[T constraints.Float] is a type returned by calling "fluentObj.It(0.9999)" used to encapsulate the "*testing.T" object and testable subject.

NOTE: The "It()" method in the example accepts any float number as per constraint "constraints.Float".

func (*Subject[T]) Should

func (s *Subject[T]) Should() IComparable[T]

Should starts the testing operations agains the Mock subject, returning an "*Comparable[T]" object which provides a set of easy-to-use methods to test the subject in an additive maner.

type Testable

type Testable[T constraints.Float] struct {
	// contains filtered or unexported fields
}

Testable[T constraints.Float] is a type that holds the "*testing.T" object and the underline Mock object, supporting further testing using the chain of easy-to-use methods. It's used by the "Subject[T constraints.Float]" and "Comparable[T constraints.Float]" types.

Jump to

Keyboard shortcuts

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