Skip to content

Commit 2ac62f3

Browse files
committed
Add tests for the quantifier statements inside an assume context,
to make sure they behave as expected.
1 parent f954730 commit 2ac62f3

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdlib.h>
2+
3+
// clang-format off
4+
int main(int argc, char **argv)
5+
{
6+
int *i = malloc(sizeof(int));
7+
*i = 1;
8+
9+
// The exists inside the assume will evaluate to true,
10+
// and be flipped by the negation in front of it, resulting
11+
// to assume(false), which will allow the assertion to evaluate
12+
// to true.
13+
__CPROVER_assume(
14+
!__CPROVER_exists{int z; (z > 1 && z < 10) && z > *i}
15+
);
16+
__CPROVER_assert(0, "this assertion should be satified");
17+
}
18+
// clang-format on
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
\[main\.assertion\.1\] line \d+ this assertion should be satified: SUCCESS
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring forall
10+
--
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <stdlib.h>
2+
3+
// clang-format off
4+
int main(int argc, char **argv)
5+
{
6+
int *i = malloc(sizeof(int));
7+
*i = 1;
8+
9+
// The exists inside the assume will evaluate to true,
10+
// and as such, the assertion below will fail as expected.
11+
__CPROVER_assume(
12+
__CPROVER_exists{int z; (z > 1 && z < 10) && z > *i}
13+
);
14+
__CPROVER_assert(0, "this should come out as failure");
15+
}
16+
// clang-format on
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
test2.c
3+
--pointer-check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
\[main\.assertion\.1\] line \d+ this should come out as failure: FAILURE
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring forall
10+
--

0 commit comments

Comments
 (0)