-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
The following code results in java.lang.IllegalStateException: Gave up after finding only 1 example(s) matching the assumptions, because the generators tend to generate empty arrays. Is this expected? Interestingly it seems to happen more often if I specify larger ranges like integers().between(0, 100), integers().between(0, 100) and less if I specify a smaller range like integers().between(0, 3).
@Test
void reproduce(){
qt().forAll(stringArraysWithDefaultContent(), stringArraysWithDefaultContent())
.assuming((x, y) -> {
System.out.println(Arrays.toString(x) + ":" + Arrays.toString(y));
return true;
})
.assuming((x, y) -> !Arrays.equals(x, y))
.check((x, y) -> !Arrays.equals(x, y));
}
private static Gen<String[]> stringArraysWithDefaultContent() {
return stringArrays(integers().between(0, 20), strings().allPossible().ofLengthBetween(0, 1));
}
private static Gen<String[]> stringArrays(Gen<Integer> sizes, Gen<String> contents) {
Gen<String[]> gen = td -> {
int size = sizes.generate(td);
String[] ds = new String[size];
for (int i = 0; i != size; i++) {
ds[i] = contents.generate(td);
}
return ds;
};
return gen.describedAs(Arrays::toString);
}The output of the snippet:
[, 㟔, , , , ?, 剜, , , ?, , ?, ]:[, Ⅾ, ?, , , ?, ?, ?, 翴, ?, ?, , ?, , , ?, , ?]
[]:[]
[]:[, , !, , , , , !, , , !, ]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
[]:[]
Metadata
Metadata
Assignees
Labels
No labels