Skip to content

No true branch test is generated for code with String.split(";\\s") #885 #914

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

Merged

Conversation

Markoutte
Copy link
Collaborator

Description

RegexModelProvider now recognize argument of method "String.split" call as a pattern to produce initial string from regex.

Fixes #885

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Testing

Manual Scenario

Try to generate test as in #885

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 Sep 13, 2022
@Markoutte Markoutte requested a review from dtim September 13, 2022 10:46
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.

The fix looks good. It seems that it is possible to cover a few more cases by extracting regexes from replaceFirst and replaceAll calls on String.

return when {
method.classId == Pattern::class.java.id -> true
method.classId == String::class.java.id && method.name == "matches" -> true
method.classId == String::class.java.id && stringMethodWithRegexArguments.contains(method.name) -> true
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are two more methods of String that accept regexes:

  • public String replaceFirst​(String regex, String replacement)
  • public String replaceAll(String regex, String replacement)

@Markoutte Markoutte merged commit daa8aaa into main Sep 13, 2022
@Markoutte Markoutte deleted the pelevin/885_No_true_branch_test_is_generated_for_code branch September 13, 2022 12:56
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
None yet
Development

Successfully merging this pull request may close these issues.

No true branch test is generated for code with String.split(";\\s")
2 participants