Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mixedCase arbitrary #426

Closed
dubzzz opened this issue Sep 6, 2019 · 0 comments · Fixed by #427
Closed

Add mixedCase arbitrary #426

dubzzz opened this issue Sep 6, 2019 · 0 comments · Fixed by #427

Comments

@dubzzz
Copy link
Owner

dubzzz commented Sep 6, 2019

🚀 Feature Request

Add mixedCase(arb: Arbitrary<string>): Arbitrary<string>

Motivation

Among the arbitraries provided by fast-check, some of them would need to have a lower-case only version plus a mixed-case version.

Indeed by default Ipv6 addresses or UUID or hexaString are using lower-case characters only. But it would be quite useful to offer a mixed-case version for each of them to diagnose issues using even stranger entries.

Implementing a mixedCase(arb: Arbitrary<string>): Arbitrary<string> can be done with a basic chain but it comes with a poor shrinker. As the need is not restricted to one precise case it should be part of the basic arbitraries provided by fast-check.

Example

fc.mixedCase(fc.hexaString()) might produce 0Ee5bA while hexaString only was limited to 0ee5ba.

@dubzzz dubzzz self-assigned this Sep 6, 2019
dubzzz added a commit that referenced this issue Sep 6, 2019
dubzzz added a commit that referenced this issue Sep 8, 2019
* Add mixedCase arbitrary

Fixes #426

* Extract countToggledBits outside of the class

* Remove unused code

* Extract computeNextFlags

* Draft units

* Fix MixedCaseArbitrary tests

* Add basic itest for mixedCase

* Add more units

* Bug for flags=2n, nextSize=1

* Add units related to shrinker

* Update snapshots

* Better jsdoc

* Do not shrink on string if we shrunk on bigint before

* Update markdown documentation

* Add warning concerning the need for bigint support

* Lint code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant