GithubHelp home page GithubHelp logo

Comments (6)

jlink avatar jlink commented on August 15, 2024 1

New features available in 1.8.0-SNAPSHOT

from jqwik.

jlink avatar jlink commented on August 15, 2024

@esfomeado Thanks for raising that issue.
I see why you‘d expect that repeatChars(0) to not create any duplicate chars at all. Currently it just sets the probability of explicitly adding duplicate chars to 0. The effect you see is due to edge case resolution.

I’ll have to think about if changing the behaviour or documentation of repeatChars is the right thing to do. Maybe an additional uniqueChars() would be even clearer.

To solve your problem short-term, you can use withoutEdgeCases() on the strings arbitrary:

Arbitraries.strings().alpha()
		   .ofMinLength(5).ofMaxLength(25)
		   .repeatChars(0.0)
		   .withoutEdgeCases();

This will prevent „AAAAA“ to be generated on purpose. Duplicate chars will still occur by chance though.

If you definitely want no duplicates, you’d currently have to take a detour through something like:

Arbitraries.chars().alpha().list()
		   .ofMinSize(5).ofMaxSize(25)
		   .uniqueElements()
		   .map(chars -> chars.stream().map(String::valueOf).collect(Collectors.joining()));

from jqwik.

jlink avatar jlink commented on August 15, 2024

I decided to introduce an experimental new API method: StringArbitrary.uniqueChars()

The open question is if StringArbitrary.repeatChars(0.0) should log a warning or just call uniqueChars implicitly, or both?

@esfomeado What do you think?

from jqwik.

esfomeado avatar esfomeado commented on August 15, 2024

Thanks for the quick response.

@jlink Personally I would expect to have the same behaviour was uniqueChars when set to 0 so I would say to just call uniqueChars implicitly.

from jqwik.

jlink avatar jlink commented on August 15, 2024

The StringArbitrary.uniqueChars() functionality and the fix for repeatChars(0.0) is available in 1.8.0-SNAPSHOT.

from jqwik.

jlink avatar jlink commented on August 15, 2024

In addition, there's now an annotation @UniqueChars that can be applied to any String parameter in a property.

from jqwik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.