
smallcheck.generators.IntegerGen 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 com.google.common.collect.Streams;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Supplier;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* Generates integers.
* First 0,1,2,3,...,depth
* Then -1,-2,...,-depth
*/
public class IntegerGen extends SeriesGen {
@Override
public Stream generate(int depth) {
return Streams.stream(new Iterator() {
int p = -1;
int n = 0;
@Override
public boolean hasNext() {
return p <= depth && n > -depth;
}
@Override
public Integer next() {
if (p < depth) {
p++;
return p;
} else {
n--;
return n;
}
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy