pub struct Harness { /* private fields */ }
Expand description

A test harness that can run many strategies on many puzzles.

When you want to test your strategies, create a new test harness with new(). You can then configure it using various methods. Note that these configuration methods consume the existing Harness and return a new one.

Examples

use wordle_rs::strategy::stupid::Stupid;

let harness = Harness::new()
    .verbose(false)
    .add_strategy(Box::new(Stupid), None)
    .parallel(false)
    .test_num(50);

let results = harness.run();

Implementations

Creates a new test harness with default configuration.

Defaults
  1. tests no strategies
  2. verbose mode
  3. runs each strategy on 100 puzzles chosen at random
  4. does not compare against a baseline
  5. runs strategies sequentially without rayon

Makes the harness verbose while testing.

As of right now, this consists of a progress bar and nothing else.

Tells the harness to run strategies in parallel.

Adds a strategy to the harness for testing.

Adds a Vec of strategies to the harness for testing.

Adds a strategy to the harness for testing and sets it as the baseline for comparison.

Sets the most recently added strategy as the baseline for comparisons.

This is supported on crate feature serde only.

Adds a saved performance record as the baseline for comparisons.

The name must match the name of a baseline saved previously.

Sets the harness to test each strategy on each possible Wordle answer.

Sets the harness to test each strategy on n random Wordle answers.

Runs the test harness on a specific set of words without parallelism.

This function will catch panics in strategies and print them as errors along with the word the strategy was trying to solve, which is useful for finding bugs in Strategy implementations.

If None is passed instead of a word list, the harness will run the strategies on all possible answers.

Note that this function will ignore the testing and parallelism settings of the harness.

Runs the harness and produces performances for each strategy.

The Perfs will be in the same order as the strategies were added to the harness.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Set the foreground color generically Read more

Set the background color generically. Read more

Change the foreground color to black

Change the background color to black

Change the foreground color to red

Change the background color to red

Change the foreground color to green

Change the background color to green

Change the foreground color to yellow

Change the background color to yellow

Change the foreground color to blue

Change the background color to blue

Change the foreground color to magenta

Change the background color to magenta

Change the foreground color to purple

Change the background color to purple

Change the foreground color to cyan

Change the background color to cyan

Change the foreground color to white

Change the background color to white

Change the foreground color to the terminal default

Change the background color to the terminal default

Change the foreground color to bright black

Change the background color to bright black

Change the foreground color to bright red

Change the background color to bright red

Change the foreground color to bright green

Change the background color to bright green

Change the foreground color to bright yellow

Change the background color to bright yellow

Change the foreground color to bright blue

Change the background color to bright blue

Change the foreground color to bright magenta

Change the background color to bright magenta

Change the foreground color to bright purple

Change the background color to bright purple

Change the foreground color to bright cyan

Change the background color to bright cyan

Change the foreground color to bright white

Change the background color to bright white

Make the text bold

Make the text dim

Make the text italicized

Make the text italicized

Make the text blink

Make the text blink (but fast!)

Swap the foreground and background colors

Hide the text

Cross out the text

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more

Set the foreground color to a specific RGB value.

Set the background color to a specific RGB value.

Sets the foreground color to an RGB value.

Sets the background color to an RGB value.

Apply a runtime-determined style

This is supported on crate feature supports-colors only.

Apply a given transformation function to all formatters if the given stream supports at least basic ANSI colors, allowing you to conditionally apply given styles/colors. Read more

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.