Skip to content

Commit d1ddad6

Browse files
author
Thomas Kiley
committed
Add negation tests for array equal
This ensures the condition doesn't introduce too strong constraints
1 parent 405b639 commit d1ddad6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

regression/cbmc/Array_operations1/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void test_unequal()
1919

2020
__CPROVER_assert(
2121
!__CPROVER_array_equal(a1, a2), "different sizes arrays are unequal");
22+
__CPROVER_assert(__CPROVER_array_equal(a1, a2), "expected to fail");
2223

2324
float a3[10];
2425
void *lost_type1 = a1;
@@ -27,6 +28,15 @@ void test_unequal()
2728
__CPROVER_assert(
2829
!__CPROVER_array_equal(lost_type1, lost_type3),
2930
"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");
3040
}
3141

3242
void test_copy()

regression/cbmc/Array_operations1/test.desc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ main.c
55
^SIGNAL=0$
66
^\[test_copy\.assertion\.4\] .* expected to fail: FAILURE$
77
^\[test_unequal\.assertion\.1\] .* different sizes arrays are unequal: SUCCESS
8-
^\[test_unequal\.assertion\.2\] .* different typed arrays are unequal: SUCCESS
9-
^\*\* 1 of 10 failed
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
1014
^VERIFICATION FAILED$
1115
--
1216
^warning: ignoring

0 commit comments

Comments
 (0)