testy

package module
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 8 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 implements some helpers for writing tests.

Package testy implements some helpers for writing tests.

Package testy implements some helpers for writing tests.

Package testy implements some helpers for writing tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t *testing.T, v bool, msg ...interface{})

Assert checks that value is true.

func AssertEqual

func AssertEqual(t *testing.T, v1, v2 interface{}, msg ...interface{})

AssertEqual checks that two values are equal.

func AssertEqualFloat32 added in v0.6.0

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

AssertEqualFloat32 checks that two float32 values are equal.

func AssertEqualFloat64 added in v0.6.0

func AssertEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...interface{})

AssertEqualFloat64 checks that two float64 values are equal.

func AssertError

func AssertError(t *testing.T, err error, msg ...interface{})

AssertError checks that error is not nil.

func AssertErrorIs added in v0.7.0

func AssertErrorIs(t *testing.T, err error, target error, msg ...interface{})

AssertError checks that error is wanted.

func AssertFalse

func AssertFalse(t *testing.T, v bool, msg ...interface{})

AssertFalse checks that value is false.

func AssertNoErr

func AssertNoErr(t *testing.T, err error, msg ...interface{})

AssertNoErr check if error is nil.

func AssertNotEqual

func AssertNotEqual(t *testing.T, v1, v2 interface{}, msg ...interface{})

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 ...interface{})

AssertNotEqualFloat32 checks that two float32 values are not equal.

func AssertNotEqualFloat64 added in v0.6.0

func AssertNotEqualFloat64(t *testing.T, v1, v2 float64, eps float64, msg ...interface{})

AssertNotEqualFloat64 checks that two float64 values are not equal.

func AssertNotNil

func AssertNotNil(t *testing.T, v interface{}, msg ...interface{})

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 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 ...interface{})

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