algtest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package algtest provides algorithm test suites.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertChainAlgorithmGenerates

func AssertChainAlgorithmGenerates(t *testing.T, a alg.ChainAlgorithm, n *big.Int, expect addchain.Chain)

AssertChainAlgorithmGenerates asserts that the algorithm generates the expected chain for n.

func AssertChainAlgorithmProduces

func AssertChainAlgorithmProduces(t *testing.T, a alg.ChainAlgorithm, n *big.Int) addchain.Chain

AssertChainAlgorithmProduces verifies that a returns a valid chain for n.

func AssertSequenceAlgorithmProduces

func AssertSequenceAlgorithmProduces(t *testing.T, a alg.SequenceAlgorithm, targets []*big.Int) addchain.Chain

AssertSequenceAlgorithmProduces verifies that a returns a valid chain containing targets.

func ChainAlgorithm

func ChainAlgorithm(t *testing.T, a alg.ChainAlgorithm)

ChainAlgorithm applies a generic test suite to the algorithm a.

func ChainAlgorithmSuite

func ChainAlgorithmSuite(a alg.ChainAlgorithm) func(t *testing.T)

ChainAlgorithmSuite builds a generic test suite function for the algorithm a.

Types

type SequenceAlgorithmSuite

type SequenceAlgorithmSuite struct {
	// Algorithm under test.
	Algorithm alg.SequenceAlgorithm

	// AcceptsLargeInputs indicates whether the algorithm can tolerate large
	// inputs. As a rule of thumb, set this to true if the algorithm is
	// logarithmic in the largest input.
	AcceptsLargeInputs bool
}

SequenceAlgorithmSuite builds a generic suite of tests for an addition sequence algorithm.

func (SequenceAlgorithmSuite) Tests

func (s SequenceAlgorithmSuite) Tests() func(t *testing.T)

Tests builds the test suite function. Suitable to run as a subtest with testing.T.Run.

Jump to

Keyboard shortcuts

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