internal

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expect

func Expect[A any](t testing.TB, actual A, m Matcher[A])
Example
package main

import (
	"fmt"

	"github.com/xoctopus/x/testx"
	"github.com/xoctopus/x/testx/internal"
	"github.com/xoctopus/x/testx/testutil"
)

type uncomparable struct {
	x []int
}

func main() {
	t := &testutil.MockTB{}

	t.Reset()
	internal.Expect(t, uncomparable{x: []int{1}}, testx.Equal(uncomparable{x: []int{2}}))
	fmt.Println(t.Output2())

	t.Reset()
	internal.Expect(t, uncomparable{x: []int{1}}, testx.NotEqual(uncomparable{x: []int{1}}))
	fmt.Println(t.Output2())

	t.Reset()
	internal.Expect(t, 1.2, testx.BeAssignableTo[int]())
	fmt.Println(t.Output2())

}
Output:
should Equal, but got
  strings.Join({
  	"internal_test.uncomparable:{x:[",
- 	"2",
+ 	"1",
  	"]}",
  }, "")

should not Equal, but got
{[1]}

should BeAssignableTo[int], but got
1.2

Types

type Matcher

type Matcher[Actual any] interface {
	// Action returns matching action name
	Action() string
	// Match defines matching action
	Match(Actual) bool
	// Negative returns if negative action. eg: Equal, NotEqual
	Negative() bool
}

func NewMatcher

func NewMatcher[A any](action string, match func(A) bool) Matcher[A]

func Not

func Not[Actual any](matcher Matcher[Actual]) Matcher[Actual]

type MatcherNewer

type MatcherNewer[Actual any, Expect any] func(expect Expect) Matcher[Actual]

func NewComparedMatcher

func NewComparedMatcher[Actual any, Expect any](action string, match func(Actual, Expect) bool) MatcherNewer[Actual, Expect]

type NormalizedExpectedMatcher

type NormalizedExpectedMatcher interface {
	NormalizeExpect() any
}

type NormalizedMatcher

type NormalizedMatcher[T any] interface {
	NormalizeActual(T) any
}

Jump to

Keyboard shortcuts

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