testy

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 7 Imported by: 0

README

testy

Helpers for reducing the amount of code in tests

Example

import (
    "github.com/aleneus/testy"
    "testing"
)

func TestSomething(t *testing.T) {
    testy.AssertEqual(t, 2*2, 4)
}

Documentation

Overview

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Package testy provides the assert helpers for writing unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t *testing.T, v bool, msg ...any)

Assert checks that value is true.

func AssertEqual

func AssertEqual(t *testing.T, v1, v2 any, msg ...any)

AssertEqual checks that two values are equal.

func AssertEqualComplex added in v0.8.0

func AssertEqualComplex(t *testing.T, c1, c2 complex128, eps float64, msg ...any)

AssertEqualComplex checks that two complex values are almost equal.

func AssertEqualFloat32 added in v0.6.0

func AssertEqualFloat32(t *testing.T, v1, v2 float32, eps float64, msg ...any)

AssertEqualFloat32 checks that two float32 values are equal with absolute eps.

func AssertEqualFloat64 added in v0.6.0

func AssertEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...any)

AssertEqualFloat64 checks that two float64 values are equal with absolute eps.

func AssertError

func AssertError(t *testing.T, err error, msg ...any)

AssertError checks that error is not nil.

func AssertErrorIs added in v0.7.0

func AssertErrorIs(t *testing.T, err error, target error, msg ...any)

AssertError checks that error is wanted.

func AssertFalse

func AssertFalse(t *testing.T, v bool, msg ...any)

AssertFalse checks that value is false.

func AssertNoErr

func AssertNoErr(t *testing.T, err error, msg ...any)

AssertNoErr check if error is nil.

func AssertNotEqual

func AssertNotEqual(t *testing.T, v1, v2 any, msg ...any)

AssertNotEqual checks that two values are not equal.

func AssertNotEqualFloat32 added in v0.6.0

func AssertNotEqualFloat32(t *testing.T, v1, v2 float32, eps float64, msg ...any)

AssertNotEqualFloat32 checks that two float32 values are not equal with absolute eps.

func AssertNotEqualFloat64 added in v0.6.0

func AssertNotEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...any)

AssertNotEqualFloat64 checks that two float64 values are not equal with absolute eps.

func AssertNotNil

func AssertNotNil(t *testing.T, v any, msg ...any)

AssertNotNil checks that value is not nil.

func AssertNotSubstr added in v0.5.0

func AssertNotSubstr(t *testing.T, substr, str string)

AssertNotSubstr asserts that first string is not substring of the second one.

func AssertPanic

func AssertPanic(t *testing.T, f func())

AssertPanic asserts that call of f gives panic.

func AssertRelEqualFloat32 added in v0.9.0

func AssertRelEqualFloat32(t *testing.T, v1, v2 float32, eps float64, msg ...any)

AssertRelEqualFloat32 checks that two float32 values are equal with relative eps.

func AssertRelEqualFloat64 added in v0.9.0

func AssertRelEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...any)

AssertRelEqualFloat64 checks that two float64 values are equal with relative eps.

func AssertRelNotEqualFloat32 added in v0.9.0

func AssertRelNotEqualFloat32(t *testing.T, v1, v2 float32, eps float64, msg ...any)

AssertRelNotEqualFloat32 checks that two float32 values are not equal with relative eps.

func AssertRelNotEqualFloat64 added in v0.9.0

func AssertRelNotEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...any)

AssertRelNotEqualFloat64 checks that two float64 values are not equal.

func AssertSubstr

func AssertSubstr(t *testing.T, substr, str string)

AssertSubstr asserts that first string is substring of the second one.

func AssertTrue

func AssertTrue(t *testing.T, v bool, msg ...any)

AssertTrue checks that value is true.

func CopyFile

func CopyFile(src string, dest string) (err error)

CopyFile copies file.

func FileSize

func FileSize(name string) (size int64, err error)

FileSize returns the file size.

Types

type Writer added in v0.5.0

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

Writer is the very simple text writer. It can be used for testing log messages for example.

func (*Writer) Pop added in v0.5.0

func (w *Writer) Pop() string

Pop returns all content and clears writer.

func (*Writer) Write added in v0.5.0

func (w *Writer) Write(data []byte) (int, error)

Write adds data to writer.

Jump to

Keyboard shortcuts

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