forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This function behaves slightly differently from StringBuilder.insert since it never raise an exception. This tests the cases where the index exceeds the limits.
- Loading branch information
1 parent
5f96226
commit 4be7532
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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,48 @@ | ||
|
||
public class Test { | ||
public void check (int i) { | ||
if(i == 0) | ||
{ | ||
// Arrange | ||
StringBuilder s = new StringBuilder("bar"); | ||
|
||
// Act | ||
s = org.cprover.CProverString.insert(s, 0, "foo"); | ||
|
||
// Should succeed | ||
assert s.toString().equals("foobar"); | ||
|
||
// Should fail | ||
assert !s.toString().equals("foobar"); | ||
} | ||
if(i == 1) | ||
{ | ||
// Arrange | ||
StringBuilder s = new StringBuilder("bar"); | ||
|
||
// Act | ||
s = org.cprover.CProverString.insert(s, -10, "foo"); | ||
|
||
// Should succeed | ||
assert s.toString().equals("foobar"); | ||
|
||
// Should fail | ||
assert !s.toString().equals("foobar"); | ||
} | ||
if(i == 2) | ||
{ | ||
// Arrange | ||
StringBuilder s = new StringBuilder("bar"); | ||
|
||
// Act | ||
s = org.cprover.CProverString.insert(s, 10, "foo"); | ||
|
||
// Should succeed | ||
assert s.toString().equals("barfoo"); | ||
|
||
// Should fail | ||
assert !s.toString().equals("barfoo"); | ||
} | ||
|
||
} | ||
} |
This file contains 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 @@ | ||
CORE | ||
Test.class | ||
--refine-strings --function Test.check | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
assertion at file Test.java line 13 .*: SUCCESS | ||
assertion at file Test.java line 16 .*: FAILURE | ||
assertion at file Test.java line 27 .*: SUCCESS | ||
assertion at file Test.java line 30 .*: FAILURE | ||
assertion at file Test.java line 41 .*: SUCCESS | ||
assertion at file Test.java line 44 .*: FAILURE | ||
-- |