File tree 3 files changed +37
-0
lines changed
jbmc/regression/jbmc-strings/StringHashCode
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Test {
2
+
3
+ public static int check (String s , int nondet ) {
4
+ if (s == null )
5
+ return -1 ;
6
+
7
+ if (nondet == 0 ) {
8
+ // This is always true
9
+ assert "foo" .hashCode () == 101574 ;
10
+ } else if (nondet == 1 ) {
11
+ // This is always false
12
+ assert "foo" .hashCode () != 101574 ;
13
+ } else if (nondet == 2 ) {
14
+ // This is sometimes false
15
+ assert !s .startsWith ("foo" ) && s .hashCode () == 101574 ;
16
+ } else if (nondet == 3 ) {
17
+ // This is always true
18
+ assert s .hashCode () == 101574 || !(s .startsWith ("foo" ) && s .length () == 3 );
19
+ } else {
20
+ // This is always false
21
+ assert "bar" .hashCode () == 101574 ;
22
+ }
23
+
24
+ return s .hashCode ();
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --max-nondet-string-length 1000 --function Test.check --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --unwind 10
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ assertion at file Test.java line 8 function .*: SUCCESS
7
+ assertion at file Test.java line 11 function .*: FAILURE
8
+ assertion at file Test.java line 14 function .*: FAILURE
9
+ assertion at file Test.java line 17 function .*: SUCCESS
10
+ assertion at file Test.java line 20 function .*: FAILURE
11
+
You can’t perform that action at this time.
0 commit comments