Skip to content

Commit 0ab62f1

Browse files
committed
Add regression tests for plus_exprt conversion
1 parent 34c5367 commit 0ab62f1

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdint.h>
2+
3+
#define NULL (void *)0
4+
5+
int main()
6+
{
7+
int32_t *a;
8+
__CPROVER_assume(a != NULL);
9+
int32_t *z = a + 2 * sizeof(int32_t);
10+
11+
__CPROVER_assert(a != z, "expected successful because of pointer arithmetic");
12+
__CPROVER_assert(a == z, "expected failure because of pointer arithmetic");
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
addition_compound_expr.c
3+
--trace
4+
\[main\.assertion\.1\] line \d+ expected successful because of pointer arithmetic: SUCCESS
5+
\[main\.assertion\.2\] line \d+ expected failure because of pointer arithmetic: FAILURE
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
This is testing the same thing as the test in addition_simple.desc, with the
11+
difference being that the addition expression here is compound, containing a
12+
more elaborate operand in the form of a multiplication containing a sizeof
13+
operator.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#define NULL (void *)0
2+
3+
int main()
4+
{
5+
int *x;
6+
int *y = x + 1;
7+
__CPROVER_assume(x != NULL);
8+
__CPROVER_assume(y != NULL);
9+
10+
__CPROVER_assert(y == x, "expected false after pointer manipulation");
11+
__CPROVER_assert(y != x, "expected true");
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
addition_simple.c
3+
--trace
4+
\[main\.assertion\.1\] line \d+ expected false after pointer manipulation: FAILURE
5+
\[main\.assertion\.2\] line \d+ expected true: SUCCESS
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
--
10+
This is testing basic pointer arithmetic by adding by incrementing a pointer's
11+
address and assigning that value to another pointer, then asserting that they
12+
don't point to the same thing.

0 commit comments

Comments
 (0)