anftest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package anftest defines a test suite for anf set implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestSet

func TestSet(t *testing.T, specFactory func() RapidSpec)

TestSet runs the full battery of tests for an anf set implementation. You provide a function that creates a new RapidSpec for each test case. (That ensures each test case generates fresh random data independent of any other test case.)

Types

type RapidSpec

type RapidSpec interface {
	// RandomElement returns a [rapid] generator that produces a random instance
	// of your set element type.
	//
	// If you cannot generate an appropriate result, return nil.  This will
	// cause the test case to be skipped.
	RandomElement() *rapid.Generator[any]

	// SingletonSet returns an [anf.Set] containing only the given element.
	SingletonSet(element any) anf.Set

	// RandomSet returns a [rapid] generator that produces a random set.  You do
	// not have to guarantee that the set is empty, even in min is > 0.  (With
	// an ANF set, we can't assume that a set with a non-empty set of clauses is
	// empty.)
	//
	// If you cannot generate an appropriate result, return nil.  This will
	// cause the test case to be skipped.
	RandomSet(min, max int) *rapid.Generator[anf.Set]

	// RandomElementOf returns a [rapid] generator that produces a random
	// element of a particular set.  Be careful not to be too aggressive about
	// using [rapid.Generator.Filter], since if that returns false too often
	// your tests can fail due to not being able to generate enough valid test
	// instances.
	//
	// If you cannot generate an appropriate result, return nil.  This will
	// cause the test case to be skipped.
	RandomElementOf(set anf.Set) *rapid.Generator[any]
}

RapidSpec provides rapid generators for the elements and sets that you are testing.

Jump to

Keyboard shortcuts

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