graphtest

package
v0.0.0-...-a09f9a9 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Graph

func Graph(
	t TestingT,
	graphBuilder func() graph.Graph[int],
	mutableOrImmutable Mutability,
	directedOrUndirected DirectionMode,
	allowsOrDisallowsSelfLoops SelfLoopsMode,
)

Graph produces a suite of test cases for testing implementations of the graph.Graph and graph.MutableGraph interfaces. Graph instances created for testing are to have int nodes.

Test cases that should be handled similarly in any graph implementation are included in this function; for example, testing that Nodes method returns the set of the nodes in the graph. Details of specific implementations of the graph.Graph and graph.MutableGraph interfaces are not tested.

Types

type DirectionMode

type DirectionMode int
const (
	Directed DirectionMode = iota
	Undirected
)

type Mutability

type Mutability int
const (
	Mutable Mutability = iota
	Immutable
)

type SelfLoopsMode

type SelfLoopsMode int
const (
	AllowsSelfLoops SelfLoopsMode = iota
	DisallowsSelfLoops
)

type TestingT

type TestingT interface {
	Helper()
	Fatalf(format string, args ...any)
	Run(name string, f func(t *testing.T)) bool
}

TestingT is an interface for the parts of *testing.T that graphtest.Graph needs to run. Whenever you see an argument of this type, pass in an instance of *testing.T or your unit testing framework's equivalent.

Jump to

Keyboard shortcuts

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