Skip to content

Add and use CProverString.ofCharArray #9

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
merged 2 commits into from
Oct 17, 2018

Conversation

romainbrenguier
Copy link
Contributor

This adds a function for converting char arrays to strings and use it
for a String constructor.

*
* @diffblue.noSupport
* @diffblue.fullSupport
* @diffblue.untested
Copy link
Member

Choose a reason for hiding this comment

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

How is this going to be tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's tested by this PR diffblue/cbmc#2374 but maybe we should have more tests in the models library.

Copy link

@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.

Only some documentation changes requested.

@@ -216,11 +237,11 @@ public String(char value[]) {
* characters outside the bounds of the {@code value} array
*
* @diffblue.limitedSupport
Copy link

Choose a reason for hiding this comment

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

Why limitedSupport now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reasons are detailed below: count limited by unwind, and value cannot be null.

* Converts an array of characters to a string. This uses a loop and
* therefore in test-generation the {@code count} will be limited by the
* unwind parameter.
* This assumes {@code value} is not null, its length is greater or equal to
Copy link

Choose a reason for hiding this comment

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

This assumes is a bit ambiguous. It looks like a precondition to the function. Maybe This constrains {@code value} to be not null...?

*
* @param value Array of characters which is the source to copy from
* @param offset Index in {@code value} of the first character to copy
* @param count Number of characters to copy
Copy link

Choose a reason for hiding this comment

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

We don't usually start the parameter description with an upper-case char.

Copy link
Member

Choose a reason for hiding this comment

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

Hm. True, lower case seems standard in javadoc.

* therefore in test-generation the {@code count} will be limited by the
* unwind parameter.
* This assumes {@code value} is not null, its length is greater or equal to
* {@code offset + count} and {@code offset} and {@code count} are positive.
Copy link

Choose a reason for hiding this comment

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

positive -> non-negative.

romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Aug 28, 2018
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Aug 29, 2018
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Sep 5, 2018
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Sep 10, 2018
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Sep 11, 2018
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Oct 2, 2018
@romainbrenguier romainbrenguier force-pushed the romain/string-of-char-array branch from dda318a to 598f37f Compare October 2, 2018 07:58
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Oct 3, 2018
*
* @param value Array of characters which is the source to copy from
* @param offset Index in {@code value} of the first character to copy
* @param count Number of characters to copy
Copy link
Member

Choose a reason for hiding this comment

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

Hm. True, lower case seems standard in javadoc.

* @return The created String
*/
public static String ofCharArray(char value[], int offset, int count) {
org.cprover.CProver.assume(value != null);
Copy link
Member

Choose a reason for hiding this comment

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

import

romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Oct 16, 2018
@romainbrenguier romainbrenguier force-pushed the romain/string-of-char-array branch from 598f37f to da73286 Compare October 17, 2018 14:59
This adds a function for converting char arrays to strings and use it
for a String constructor.
@romainbrenguier romainbrenguier force-pushed the romain/string-of-char-array branch from da73286 to b7ca9fd Compare October 17, 2018 16:42
@romainbrenguier romainbrenguier merged commit 3163b09 into master Oct 17, 2018
@romainbrenguier romainbrenguier deleted the romain/string-of-char-array branch October 17, 2018 17:28
romainbrenguier added a commit to romainbrenguier/cbmc that referenced this pull request Oct 17, 2018
xbauch pushed a commit to xbauch/cbmc that referenced this pull request Nov 9, 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.

3 participants