Skip to content

Use regex for generating string when regex pattern is found #778 #793

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

Conversation

Markoutte
Copy link
Collaborator

Description

Now fuzzer searches for regexes from these places:

String.matches(regex)
Pattern.*(regex)

If any is found then it generates and mutates string values using found regex.

Fixes #778

Type of Change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Automated Testing

org.utbot.framework.plugin.api.ModelProviderTest

Manual Scenario

Try this example with only fuzzing:

public boolean isValidDouble(String value) {
    return value.matches("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?([fFdD]?)\n") && value.contains("E") && value.contains("-");
}

It should generate the correct values like +727498D, +0.402E-816f, +0046.827E+92629d.

Checklist:

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@Markoutte Markoutte added the comp-fuzzing Issue is related to the fuzzing label Aug 26, 2022
@Markoutte Markoutte requested a review from dtim August 26, 2022 07:23
Copy link
Collaborator

@dtim dtim left a comment

Choose a reason for hiding this comment

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

LGTM (there is a stylistic comment, but it seems to be just a matter of taste)

LE("<="),
;

fun reverse(): Comparison = when (this) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Java Comparator<T> interface (and its counterpart in the Kotlin stdlib) has reversed method that returns a comparator with reverse ordering. What do you think about using reversed() instead of reverse() here? I think it could be a bit more readable (at least it would be for me -- I used to read 'reverse()` as an in-place operation on collections).

@Markoutte Markoutte merged commit 78df295 into main Aug 26, 2022
@Markoutte Markoutte deleted the 778_Use_regex_for_generating_string_when_regex_pattern_is_found branch August 26, 2022 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-fuzzing Issue is related to the fuzzing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Use regex for generating string when regex pattern is found
2 participants