Closed
Description
Testing Problem
I had an issue where jqwik is generating duplicated values frequently which, for my example should almost never occur.
I have noticed that these duplicated values are always the same character e,g, AAAAAA
so I decided to set the repeatedChars
to 0 but this type of values are still generated. I have tried the other values but seems that there is no impact on the ammount of time a repeated char is used.
@Test
void bug() {
StringArbitrary strings = Arbitraries.strings()
.alpha()
.ofMinLength(5)
.ofMaxLength(25)
.repeatChars(0);
List<String> names = IntStream.range(0, 100)
.mapToObj(i -> strings.sample())
.toList();
Map<String, Long> duplicateCount = names.stream()
.filter(Objects::nonNull)
.collect(Collectors.groupingBy(s -> s, Collectors.counting()));
List<String> duplicateStrings = duplicateCount.entrySet().stream()
.filter(entry -> entry.getValue() > 1)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
System.out.println("Duplicate strings: " + duplicateStrings);
assertThat(duplicateStrings).isEmpty();
}