Closed mattiacolucci closed 11 months ago
@mattiacolucci Without your implementation of Homework2Object
I cannot really check what's happening here. So you may want to provide it. Or, even better, reduce the example to the bare bones, ie remove everything that's not necessary for reproducing the phenomenon.
The code of the class is the following:
class Homework2Object{
private String initialString;
private int subStringLength;
private Map<String,Integer> palindromeToPut;
public Homework2Object(String i, int l, Map<String,Integer> p){
initialString=i;
subStringLength=l;
palindromeToPut=p;
}
public String getInitialString() {
return initialString;
}
public int getSubStringLength() {
return subStringLength;
}
public Map<String,Integer> getPalindromeToPut() {
return palindromeToPut;
}
}
It's basically a class just to generate different types of data: an initilString, a random int and a map of integers and random strings as keys
@mattiacolucci The problem you are observing is not a generation problem but a shrinking bug. Thanks for catching and reporting it!
What I noticed, though, is that this line:
finalstring=finalstring.concat(initialString.substring(currIndex,currIndex+step)+key+keyReverse);
will sometimes fail with a StringIndexOutOfBoundsException
which then leads to shrinking and revealing the bug.
I suggest that I will work on the shrinking bug - and you on the failing tests logic ;-)
Released in 1.8.3-SNAPSHOT
@mattiacolucci If you want you can try your example with the snapshot release
Hi, I am using a Provide metod to generate some data like a random string withCharsRange and with no duplicates (using uniqueChars). The problem is that if I put an always true assert in the thest method (like an assertTrue(true)) the data generated is correct and the string "iniial String" doesn't present any duplicate char. But If I use the assertEquals(expected,actual) that I will use to test my method, jqwik generate a string that presents duplicates. In details, going on with the number of the test genrated, the string will contain more chars duplicated, expecially the first char of the range specified into the Arbitrary withCharsRange.
Here is the code:
The output with the assert(expected,actual) is the following:
and so on....