Skip to content

Add StringCombinableArbitrary for easy efficient customisation #1179

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seongahjo
Copy link
Contributor

@seongahjo seongahjo commented Apr 22, 2025

Summary

Add StringCombinableArbitrary for easy efficient customisation

(Optional): Description

providing below APIs to customize the randomly generated String

  • alphabetic
  • korean
  • ascii
  • numeric
  • pattern
  • withLength
  • withMinLength
  • withMaxLength

How Has This Been Tested?

  • stringCombinableArbitraryIsJqwik
  • stringCombinableArbitraryInjectNull
  • stringCombinableArbitraryFilter
  • stringCombinableArbitraryFilterCharacter
  • stringCombinableArbitraryFilterCharacterAndFilter
  • stringCombinableArbitraryNumeric
  • stringCombinableArbitraryMap
  • stringCombinableArbitraryKorean
  • stringCombinableArbitraryAlphabet
  • stringCombinableArbitraryLatterWins
  • stringCombinableArbitrary
  • stringCombinableArbitraryAscii

Is the Document updated?

Later

@seongahjo seongahjo added this to the 1.1.12 milestone Apr 22, 2025
@seongahjo seongahjo changed the title Add StringCombinableArbitrary for easy customisation Add StringCombinableArbitrary for easy efficient customisation Apr 22, 2025
@seongahjo seongahjo force-pushed the main branch 4 times, most recently from e5e944e to 3ff3180 Compare April 22, 2025 16:14
* @return the pattern matched StringCombinableArbitrary
*/
default StringCombinableArbitrary pattern(int tries, String stringPattern) {
Pattern pattern = Pattern.compile(stringPattern);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding method taking Pattern class? It seems immutable

@@ -0,0 +1 @@
com.navercorp.fixturemonkey.api.jqwik.JqwikStringCombinableArbitrary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it's already loaded (it's inside the api module). Is that ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I test it, SPI does not load the implementation implicitly.
It should specify the implementation in META-INF/services.

I also did not find the following specification in the document.

https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html

image


override fun alphabetic(): StringCombinableArbitrary = KotestStringCombinableArbitrary(
Arb.string(
codepoints = Arb.codepoints().filter { it.value.toChar() in 'a'..'z' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to include lower case only?

@seongahjo seongahjo force-pushed the sa/string-combinable-arbitrary branch from 6629cd3 to f581ee8 Compare April 28, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants