
smallcheck.generators.SetGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-smallcheck Show documentation
Show all versions of java-smallcheck Show documentation
An implementation of SmallCheck for Java as a JUnit extension.
The newest version!
package smallcheck.generators;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Stream;
/**
*
*/
public class SetGen extends SeriesGen> {
private SeriesGen elementGen;
public SetGen(SeriesGen elementGen) {
super();
this.elementGen = elementGen;
}
@Override
public Stream> generate(int depth) {
if (depth == 0) {
return Stream.of(Collections.emptySet());
}
return generate(depth - 1).flatMap(l -> {
return Stream.concat(
Stream.of(l),
elementGen.generate(depth - 1).map(e -> {
Set res = new LinkedHashSet<>(depth);
res.add(e);
res.addAll(l);
return res;
})
);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy