-
Notifications
You must be signed in to change notification settings - Fork 273
Feature/parse int#613 #1077
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
smowton
merged 4 commits into
diffblue:test-gen-support
from
owen-mc-diffblue:feature/parseInt#613
Jul 4, 2017
+358
−42
Merged
Feature/parse int#613 #1077
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+187 Bytes
(130%)
regression/strings-smoke-tests/java_parseint/test_parseint.class
Binary file not shown.
16 changes: 9 additions & 7 deletions
16
regression/strings-smoke-tests/java_parseint/test_parseint.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
public class test_parseint | ||
{ | ||
public static void main(String[] argv) | ||
{ | ||
String twelve = new String("12"); | ||
int parsed = Integer.parseInt(twelve); | ||
assert(parsed == 12); | ||
assert(parsed != 12); | ||
} | ||
public static void main(String[] args) | ||
{ | ||
if (args.length == 1) { | ||
String twelve = new String("12"); | ||
int parsed1 = Integer.parseInt(twelve); | ||
assert(parsed1 == 12); | ||
assert(parsed1 != 12); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
regression/strings-smoke-tests/java_parseint_knownbug/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
KNOWNBUG | ||
test_parseint.class | ||
--refine-strings | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[.*assertion.1\].* line 9.* SUCCESS$ | ||
^\[.*assertion.2\].* line 10.* FAILURE$ | ||
^\[.*assertion.3\].* line 17.* SUCCESS$ | ||
^\[.*assertion.4\].* line 18.* FAILURE$ | ||
-- | ||
-- | ||
Issue #664 is about turning these tests on |
Binary file added
BIN
+1.06 KB
regression/strings-smoke-tests/java_parseint_knownbug/test_parseint.class
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
regression/strings-smoke-tests/java_parseint_knownbug/test_parseint.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class test_parseint | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
if (args.length == 2) { | ||
// 2^31-1, max value of Integer | ||
String max_int = new String("2147483647"); | ||
int parsed2 = Integer.parseInt(max_int); | ||
assert(parsed2 == 2147483647); | ||
assert(parsed2 != 2147483647); | ||
} | ||
else if (args.length == 3) { | ||
// -2^31, min value of Integer, and longest string we could have without | ||
// leading zeroes | ||
String min_int = new String("-2147483648"); | ||
int parsed3 = Integer.parseInt(min_int); | ||
assert(parsed3 == -2147483648); | ||
assert(parsed3 != -2147483648); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
regression/strings-smoke-tests/java_parseint_with_radix/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CORE | ||
test_parseint_with_radix.class | ||
--refine-strings | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[.*assertion.1\].* line 8.* SUCCESS$ | ||
^\[.*assertion.2\].* line 9.* FAILURE$ | ||
^\[.*assertion.3\].* line 14.* SUCCESS$ | ||
^\[.*assertion.4\].* line 15.* FAILURE$ | ||
^\[.*assertion.5\].* line 20.* SUCCESS$ | ||
^\[.*assertion.6\].* line 21.* FAILURE$ | ||
^\[.*assertion.7\].* line 26.* SUCCESS$ | ||
^\[.*assertion.8\].* line 27.* FAILURE$ | ||
^\[.*assertion.9\].* line 32.* SUCCESS$ | ||
^\[.*assertion.10\].* line 33.* FAILURE$ | ||
-- |
Binary file added
BIN
+1.5 KB
regression/strings-smoke-tests/java_parseint_with_radix/test_parseint_with_radix.class
Binary file not shown.
36 changes: 36 additions & 0 deletions
36
regression/strings-smoke-tests/java_parseint_with_radix/test_parseint_with_radix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
public class test_parseint_with_radix | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
if (args.length == 1) { | ||
String str1 = new String("F"); | ||
int parsed1 = Integer.parseInt(str1, 16); | ||
assert(parsed1 == 15); | ||
assert(parsed1 != 15); | ||
} | ||
else if (args.length == 2) { | ||
String str2 = new String("123"); | ||
int parsed2 = Integer.parseInt(str2, 10); | ||
assert(parsed2 == 123); | ||
assert(parsed2 != 123); | ||
} | ||
else if (args.length == 3) { | ||
String str3 = new String("77"); | ||
int parsed3 = Integer.parseInt(str3, 8); | ||
assert(parsed3 == 63); | ||
assert(parsed3 != 63); | ||
} | ||
else if (args.length == 4) { | ||
String str4 = new String("-101"); | ||
int parsed4 = Integer.parseInt(str4, 2); | ||
assert(parsed4 == -5); | ||
assert(parsed4 != -5); | ||
} | ||
else if (args.length == 5) { | ||
String str5 = new String("00aB"); | ||
int parsed5 = Integer.parseInt(str5, 16); | ||
assert(parsed5 == 171); | ||
assert(parsed5 != 171); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
regression/strings-smoke-tests/java_parseint_with_radix_knownbug/test.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
KNOWNBUG | ||
test_parseint_with_radix.class | ||
--refine-strings | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^\[.*assertion.1\].* line 9.* SUCCESS$ | ||
^\[.*assertion.2\].* line 10.* FAILURE$ | ||
^\[.*assertion.3\].* line 16.* SUCCESS$ | ||
^\[.*assertion.4\].* line 17.* FAILURE$ | ||
-- | ||
-- | ||
Issue #664 is about turning these tests on |
Binary file added
BIN
+1.11 KB
...sion/strings-smoke-tests/java_parseint_with_radix_knownbug/test_parseint_with_radix.class
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
...ssion/strings-smoke-tests/java_parseint_with_radix_knownbug/test_parseint_with_radix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
public class test_parseint_with_radix | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
if (args.length == 1) { | ||
// 2^31-1, max value of Integer | ||
String str1 = new String("7FFFFFFF"); | ||
int parsed1 = Integer.parseInt(str1, 16); | ||
assert(parsed1 == 2147483647); | ||
assert(parsed1 != 2147483647); | ||
} | ||
else if (args.length == 2) { | ||
// -2^31, min value of Integer, and longest string we could have | ||
String str2 = new String("-100000000000000000000000000000000"); | ||
int parsed2 = Integer.parseInt(str2, 2); | ||
assert(parsed2 == -2147483648); | ||
assert(parsed2 != -2147483648); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the ternary conditional is the one blessed operator we're permitted spaces around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything indicating that in the coding standard. I had a quick look in the codebase and some sections use spaces and some don't. @tautschnig seems to be the authority on formatting so I found a PR of mine that he reviewed with a ternary operator in it and he didn't disapprove of having no spaces: https://github.com/diffblue/cbmc/pull/767/files#diff-ffd0a317958e24d1f65f21ed40f67c99R55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear: I'd like to use spaces, but if we are allowed to then it should be in the coding standard, so we end getting more consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat similarly to @smowton I inferred that we should use spaces with ternary from the passage that says that we should use spaces around logical operators (I see ternary as logical operator). In the code that @owen-jones-diffblue linked there is a line break after ? so it is not that bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It lists the three operators that you can have spaces around (&&, || and <<)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two of them are logical, would you also say that we are not permitted to use spaces around >> because it is not on the list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you are meant to use spaces around << when used for streams, and not use spaces around << or >> when used for bit shifting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
That was my interpretation, too.
Thank you for the clarification.