Skip to content

Make split_string check&throw instead of assert return value #3471

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

hannes-steffenhagen-diffblue
Copy link
Contributor

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue commented Nov 27, 2018

The 2-string version of split_string previously asserted that the split would
result in the right number of substrings. That made it not very useful for
parsing user input, as using it would require parsing the string before passing
it to split_string.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Contributor

@xbauch xbauch left a comment

Choose a reason for hiding this comment

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

Looks good.

throw deserialization_exceptiont{"expected string `" + s +
"' to contain two substrings "
"delimited by " +
delim + " but has " +
Copy link
Contributor

Choose a reason for hiding this comment

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

"but has" -> "but there are" (suggestion)

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

🚫
This PR failed Diffblue compatibility checks (cbmc commit: b68d590).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92679458
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@kroening
Copy link
Member

(Unrelated request, for another PR: This variant should return a std::pair<std::string, std::string>. One day, this will enable these to become std::string_view.

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the string-split-throw-instead-of-assert branch from b68d590 to 4538eaf Compare November 27, 2018 16:09
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

🚫
This PR failed Diffblue compatibility checks (cbmc commit: 4538eaf).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92726576
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

The 2-string version of split_string previously asserted that the split would
result in the right number of substrings. That made it not very useful for
parsing user input, as using it would require parsing the string before passing
it to split_string.
Copy link
Contributor

@danpoe danpoe left a comment

Choose a reason for hiding this comment

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

LGTM

"' to contain two substrings "
"delimited by " +
delim + " but has " +
std::to_string(result.size())};
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: " but has " + std::to_string(result.size()) + " substrings"

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue force-pushed the string-split-throw-instead-of-assert branch from 4538eaf to 19babdc Compare November 28, 2018 11:21
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

✔️
Passed Diffblue compatibility checks (cbmc commit: 19babdc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92836392

@NlightNFotis NlightNFotis merged commit 3e7cd4a into diffblue:develop Nov 28, 2018
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.

6 participants