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()
12
12
__CPROVER_assert (array1 [index ] == array2 [index ], "arrays are equal" );
13
13
}
14
14
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
+
15
42
void test_copy ()
16
43
{
17
44
char array1 [100 ], array2 [100 ], array3 [90 ];
@@ -54,4 +81,5 @@ int main()
54
81
test_copy ();
55
82
test_replace ();
56
83
test_set ();
84
+ test_unequal ();
57
85
}
Original file line number Diff line number Diff line change 4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
6
^\[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
8
14
^VERIFICATION FAILED$
9
15
--
10
16
^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(
240
240
241
241
// check for size (or type) mismatch
242
242
if (array1.type () != array2.type ())
243
- assignment.lhs () = false_exprt ();
243
+ assignment.rhs () = false_exprt ();
244
244
245
245
symex_assign (state, assignment);
246
246
}
You can’t perform that action at this time.
0 commit comments