harness

package
v0.0.0-...-e4d56ad Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness[T any, U comparable] struct {
	// contains filtered or unexported fields
}

Harness manages running each days' challenge code, including parsing the input before calling solve, and managing test expectations from examples.

func New

func New[T any, U comparable](solve func(T) U, opts ...HarnessOpt[T, U]) *Harness[T, U]

New returns a new Harness. At minimum a solve function and some inputs are required.

func (*Harness[T, U]) Benchmark

func (h *Harness[T, U]) Benchmark(cond benchmark.Condition)

Benchmark is a utility to run a benchmark on solve using the main input.

func (*Harness[T, U]) Expect

func (h *Harness[T, U]) Expect(n int, expected U)

Expect will set a required assertion on the output of solve for a test input.

func (*Harness[T, U]) Run

func (h *Harness[T, U]) Run()

Run will execute the harness with the main input.

type HarnessOpt

type HarnessOpt[T any, U comparable] func(harness *Harness[T, U])

HarnessOpt modifies the Harness when initialising.

func WithNoSubmit

func WithNoSubmit[T any, U comparable]() HarnessOpt[T, U]

func WithPreProcessor

func WithPreProcessor[T any, U comparable](preProcessor PreProcessor[T]) HarnessOpt[T, U]

WithPreProcessor explicitly sets the PreProcessor to be used.

func WithSilence

func WithSilence[T any, U comparable]() HarnessOpt[T, U]

type PreProcessor

type PreProcessor[T any] func(string) T

PreProcessor is a function that process the input data before passing to the solve function.

func DoubleSection

func DoubleSection() PreProcessor[[2]string]

func DoubleSectionLines

func DoubleSectionLines() PreProcessor[[2][]string]

func Grid

func Grid() PreProcessor[space.Grid[byte]]

Grid processes the input as a grid of bytes

func Ints

func Ints() PreProcessor[[][]int]

Ints process the input to a slice of ints for each line

func SplitNewlines

func SplitNewlines() PreProcessor[[]string]

SplitNewlines is the default processing that splits the input on newlines

func SplitSequence

func SplitSequence(seq string) PreProcessor[[]string]

SplitSequence trims and splits the input on the seq string sequence

Jump to

Keyboard shortcuts

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