File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed
regression/cbmc/Array_operations1 Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,33 @@ void test_equal()
1212 __CPROVER_assert (array1 [index ] == array2 [index ], "arrays are equal" );
1313}
1414
15+ void test_unequal ()
16+ {
17+ int a1 [10 ];
18+ int a2 [16 ];
19+
20+ __CPROVER_assert (
21+ !__CPROVER_array_equal (a1 , a2 ), "different sizes arrays are unequal" );
22+ __CPROVER_assert (__CPROVER_array_equal (a1 , a2 ), "expected to fail" );
23+
24+ float a3 [10 ];
25+ void * lost_type1 = a1 ;
26+ void * lost_type3 = a3 ;
27+
28+ __CPROVER_assert (
29+ !__CPROVER_array_equal (lost_type1 , lost_type3 ),
30+ "different typed arrays are unequal" );
31+ __CPROVER_assert (
32+ __CPROVER_array_equal (lost_type1 , lost_type3 ), "expected to fail" );
33+
34+ int a4 [10 ];
35+ int a5 [10 ];
36+
37+ // Here the arrays both can be equal, and be not equal, so both asserts should fail
38+ __CPROVER_assert (!__CPROVER_array_equal (a4 , a5 ), "expected to fail" );
39+ __CPROVER_assert (__CPROVER_array_equal (a4 , a5 ), "expected to fail" );
40+ }
41+
1542void test_copy ()
1643{
1744 char array1 [100 ], array2 [100 ], array3 [90 ];
@@ -54,4 +81,5 @@ int main()
5481 test_copy ();
5582 test_replace ();
5683 test_set ();
84+ test_unequal ();
5785}
Original file line number Diff line number Diff line change 44^EXIT=10$
55^SIGNAL=0$
66^\[test_copy\.assertion\.4\] .* expected to fail: FAILURE$
7- ^\*\* 1 of 8 failed
7+ ^\[test_unequal\.assertion\.1\] .* different sizes arrays are unequal: SUCCESS
8+ ^\[test_unequal\.assertion\.2\] .* expected to fail: FAILURE
9+ ^\[test_unequal\.assertion\.3\] .* different typed arrays are unequal: SUCCESS
10+ ^\[test_unequal\.assertion\.4\] .* expected to fail: FAILURE
11+ ^\[test_unequal\.assertion\.5\] .* expected to fail: FAILURE
12+ ^\[test_unequal\.assertion\.6\] .* expected to fail: FAILURE
13+ ^\*\* 5 of 14 failed
814^VERIFICATION FAILED$
915--
1016^warning: ignoring
17+ --
18+ Verify the properties of various cprover array primitves
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ void goto_symext::symex_other(
240240
241241 // check for size (or type) mismatch
242242 if (array1.type () != array2.type ())
243- assignment.lhs () = false_exprt ();
243+ assignment.rhs () = false_exprt ();
244244
245245 symex_assign (state, assignment);
246246 }
You can’t perform that action at this time.
0 commit comments