tester

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

README

Tester

This package provides various useful functions to perform tests.

This package has methods for:

  • Assertions:

    • Equality – MustBeEqual
    • Difference – MustBeDifferent
  • Checking errors:

    • Error is set – MustBeAnError
    • No error is set – MustBeNoError

These methods can be used to compare values, to check errors and even to make more complex comparisons from simple ones.

When a comparison fails, it not only shows the values which failed, but also prints a 'Diff', a difference between these values. As opposed to many existing Golang libraries in the Internet, this package uses the object-oriented programming style (O.O.P.) as in such mature programming languages as C# and Java.

Documentation

Index

Constants

View Source
const (
	ErrErrorWasExpected    = "An Error was expected, but None was received"
	ErrfNoErrorWasExpected = "No Error was expected, but One was received: %v"
	ErrfNotEqual           = `Values should be equal, but they are not. 
A=%v 
B=%v 
Diff=%v`
	ErrfNotDifferent = `Values should be different, but they are not. 
A=%v 
B=%v 
Diff=%v`
)

Error messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Test

type Test struct {
	// contains filtered or unexported fields
}

Test object helps to make tests.

func New

func New(t *testing.T) *Test

New creates a test.

func (*Test) MustBeAnError

func (test *Test) MustBeAnError(err error)

MustBeAnError ensures that the error is not nil. If the error is nil, it stops the test.

func (*Test) MustBeDifferent

func (test *Test) MustBeDifferent(a any, b any)

MustBeDifferent ensures that two variables have different values. If not, it stops the test.

func (*Test) MustBeEqual

func (test *Test) MustBeEqual(a any, b any)

MustBeEqual ensures that two variables have equal values. If not, it stops the test.

func (*Test) MustBeNoError

func (test *Test) MustBeNoError(err error)

MustBeNoError ensures that the error is nil. If the error is not nil, it stops the test.

Jump to

Keyboard shortcuts

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