typelevel / scalacheck

Property-based testing for Scala
http://www.scalacheck.org
BSD 3-Clause "New" or "Revised" License
1.94k stars 405 forks source link

Add Gen.nonEmptyStringOf #944

Closed satorg closed 1 year ago

satorg commented 1 year ago

I totally realize that there are a lot of other ways to achieve the same functionality with the existing generators, but I think it is a quite basic feature and can come handy when someone (me, personally) just needs to "grab and go" a non-empty string. So I believe it would complement the nonEmptyListOf and nonEmptyMap generators pretty well.

vivekragunathan commented 1 year ago

Curious to know if something like nonEmptySomeOf (that complements someOf) would make sense. I am not sure if such a method exists already.

rossabaker commented 1 year ago

@vivekragunathan I'd open a separate issue to discuss that one, but it doesn't sound unreasonable...

ashawley commented 1 year ago

This new method should be added to the list of definitions for string support in the docs:

https://javadoc.io/doc/org.scalacheck/scalacheck_2.13/latest/org/scalacheck/Gen.html