testify

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 4 Imported by: 0

README

Testify - a simple test enhancement library

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/testify

Getting Started

import (
  "testing"
  "github.com/go-zoox/testify"
)

func TestSomething(t *testing.T) {
  // assert ok
  testify.Assert(t, true, "this should be true")

  // equality
  testify.Equal(t, 123, 123, "they should be equal")

  // inequality
  testify.NotEqual(t, 123, 456, "they should not be equal")

  // enums
  testify.Enums(t, []string{"foo", "bar", "baz", "qux"}, "quux", "quux should be in the list")

  // type
  testify.Type(t, 123, "int", "they should be the same type")

  // range
  testify.Range(t, 0, 123, 100, "100 should be in the range")
}

License

GoZoox is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.2"

Functions

func Assert

func Assert(t *testing.T, ok bool, message ...string)

Assert logs error if not ok.

func AssertFalse added in v1.0.2

func AssertFalse(t *testing.T, received bool, message ...string)

AssertFalse asserts that the specified value is false.

func AssertTrue added in v1.0.2

func AssertTrue(t *testing.T, received bool, message ...string)

AssertTrue asserts that the specified value is true.

func Enums

func Enums[T comparable](t *testing.T, enums []T, element T, message ...string)

Enums logs error if element is not one of enums.

func Equal

func Equal[T comparable](t *testing.T, expected, received T, message ...string)

Equal logs error if expected and actual are not deeply equal.

func Includes

func Includes[T comparable](t *testing.T, list []T, item T, message ...string)

Includes logs error if expected does not includes received.

func NotEqual

func NotEqual[T comparable](t *testing.T, expected, received T, message ...string)

NotEqual logs error if expected and actual are equal.

func Range

func Range[T Number](t *testing.T, min T, max T, value T, message ...string)

Range logs error if value is not in range [min, max].

func Type

func Type(t *testing.T, typ string, value any, message ...string)

Type logs error if type is not equal with the reflect.Type of the given value. typ:

	string
	bool
 int | int8 | int16 | int32 | int64
 uint | uint8 | uint16 | uint32 | uint64
 float32 | float64
 complex64 | complex128
 byte
 rune
 error

Types

type Number added in v1.0.1

type Number interface {
	int | int64 | float64 | float32 | uint | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32
}

Jump to

Keyboard shortcuts

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