Skip to content

Commit 7094f98

Browse files
committed
Add two regression tests for pointer relational support
1 parent ebaabf9 commit 7094f98

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#define NULL (void *)0
2+
3+
int main()
4+
{
5+
int i = 12;
6+
int *x = &i;
7+
int *y = x + 1;
8+
int *z = x - 1;
9+
10+
// Assertions on y's relation to x
11+
__CPROVER_assert(y != x, "y != x: expected successful");
12+
__CPROVER_assert(y > x, "y > x: expected successful");
13+
__CPROVER_assert(y < x, "y < x: expected failure");
14+
15+
// Assertions on z's relation to x
16+
__CPROVER_assert(z != x, "z != x: expected successful");
17+
__CPROVER_assert(z > x, "z > x: expected failure");
18+
__CPROVER_assert(z < x, "z < x: expected success");
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
pointers_stack_lessthan.c
3+
--trace
4+
\[main\.assertion\.1] line \d+ y != x: expected successful: SUCCESS
5+
\[main\.assertion\.2] line \d+ y > x: expected successful: SUCCESS
6+
\[main\.assertion\.3] line \d+ y < x: expected failure: FAILURE
7+
\[main\.assertion\.4] line \d+ z != x: expected successful: SUCCESS
8+
\[main\.assertion\.5] line \d+ z > x: expected failure: FAILURE
9+
\[main\.assertion\.6] line \d+ z < x: expected success: SUCCESS
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
--
14+
This is testing basic pointer relational operator support for three objects
15+
defined in the function's stack frame.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdlib.h>
2+
3+
int main()
4+
{
5+
int *a = malloc(sizeof(int) * 5);
6+
7+
for(int i = 0; i < 5; i++)
8+
*(a + i) = i;
9+
10+
for(int i = 0; i < 5; i++)
11+
{
12+
__CPROVER_assert(*(a + i) >= i, "*(a + i) >= i: expected successful");
13+
__CPROVER_assert(*(a + i) <= i, "*(a + i) <= i: expected successful");
14+
__CPROVER_assert(*(a + i) == i, "*(a + i) <= i: expected successful");
15+
__CPROVER_assert(*(a + i) != i, "*(a + i) <= i: expected failure");
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
pointers_stack_malloc.c
3+
--trace
4+
\[main\.assertion\.1\] line \d+ \*\(a \+ i\) >= i: expected successful: SUCCESS
5+
\[main\.assertion\.2\] line \d+ \*\(a \+ i\) <= i: expected successful: SUCCESS
6+
\[main\.assertion\.3\] line \d+ \*\(a \+ i\) <= i: expected successful: SUCCESS
7+
\[main\.assertion\.4\] line \d+ \*\(a \+ i\) <= i: expected failure: FAILURE
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
This is testing the support for relational operators as applied to pointer objects
13+
backed by a malloc and initialised to some values.

0 commit comments

Comments
 (0)