All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.properties.stateful.DefaultActionSequenceArbitrary Maven / Gradle / Ivy

The newest version!
package net.jqwik.engine.properties.stateful;

import net.jqwik.api.*;
import net.jqwik.api.stateful.*;
import net.jqwik.engine.properties.arbitraries.*;

import org.jspecify.annotations.*;

public class DefaultActionSequenceArbitrary extends TypedCloneable implements ActionSequenceArbitrary {

	private final Arbitrary> actionArbitrary;

	private int size = 0;

	@SuppressWarnings("unchecked")
	public DefaultActionSequenceArbitrary(Arbitrary> actionArbitrary) {
		this.actionArbitrary = (Arbitrary>) actionArbitrary;
	}

	@Override
	public ActionSequenceArbitrary ofSize(int size) {
		DefaultActionSequenceArbitrary clone = typedClone();
		clone.size = size;
		return clone;
	}

	@Override
	public RandomGenerator> generator(int genSize) {
		final int effectiveMaxSize =
			size != 0 ? size : (int) Math.max(Math.round(Math.sqrt(genSize)), 10);
		return new ActionSequenceGenerator<>(actionArbitrary, genSize, effectiveMaxSize);
	}

	@Override
	public EdgeCases> edgeCases(int maxEdgeCases) {
		return EdgeCases.none();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy