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

net.jqwik.engine.properties.arbitraries.ChooseCharacterArbitrary Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.properties.arbitraries;

import java.util.*;

import net.jqwik.engine.properties.arbitraries.exhaustive.*;
import net.jqwik.engine.properties.arbitraries.randomized.*;

public class ChooseCharacterArbitrary extends UseGeneratorsArbitrary {

	private final char[] chars;

	public ChooseCharacterArbitrary(char[] chars) {
		super(
			RandomGenerators.choose(chars),
			max -> ExhaustiveGenerators.choose(chars, max),
			maxEdgeCases -> {
				List validCharacters = new ArrayList<>(chars.length);
				for (char character : chars) {
					validCharacters.add(character);
				}
				return EdgeCasesSupport.choose(validCharacters, maxEdgeCases);
			}
		);
		this.chars = chars;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		ChooseCharacterArbitrary that = (ChooseCharacterArbitrary) o;
		return Arrays.equals(chars, that.chars);
	}

	@Override
	public int hashCode() {
		return Arrays.hashCode(chars);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy