Skip to content

Commit b0087bd

Browse files
author
Enrico Steffinlongo
committed
Regression tests for enums in incr SMT2 solver
1 parent af49ddc commit b0087bd

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <assert.h>
2+
3+
enum E
4+
{
5+
V0 = 0,
6+
V1 = 1,
7+
V2 = 2
8+
};
9+
10+
int main()
11+
{
12+
unsigned i;
13+
__CPROVER_assume(i < 3);
14+
enum E e[3];
15+
e[0] = V0;
16+
e[1] = V1;
17+
e[2] = V2;
18+
__CPROVER_assert(e[i] > 0, "Array at index 0 is V0, so this should fail");
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
enum_in_array.c
3+
--trace
4+
Passing problem to incremental SMT2 solving
5+
line 18 Array at index 0 is V0, so this should fail: FAILURE
6+
i=0u \(00000000 00000000 00000000 00000000\)
7+
e\[0l+\]=/\*enum\*/V0 \(00000000 00000000 00000000 00000000\)
8+
e\[1l+\]=/\*enum\*/V1 \(00000000 00000000 00000000 00000001\)
9+
e\[2l+\]=/\*enum\*/V2 \(00000000 00000000 00000000 00000010\)
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
--
14+
Test that we support enum values and traces for an array of enums. At the time of adding the
15+
regression test, this exercised the conversion code specific to c_enum_tag_typet.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <assert.h>
2+
3+
enum E
4+
{
5+
V0 = 0,
6+
V1 = 1,
7+
V2 = 2
8+
};
9+
10+
struct S
11+
{
12+
enum E a;
13+
int b;
14+
};
15+
16+
int main()
17+
{
18+
struct S s;
19+
s.a = V1;
20+
__CPROVER_assume(__CPROVER_enum_is_in_range(s.a));
21+
__CPROVER_assert(s.a > 10, "Struct field s.a is V1, so this should fail");
22+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
enum_in_struct.c
3+
--trace
4+
Passing problem to incremental SMT2 solving
5+
line 21 Struct field s\.a is V1, so this should fail: FAILURE
6+
s\.a=/\*enum\*/V1 \(00000000 00000000 00000000 00000001\)
7+
^EXIT=10$
8+
^SIGNAL=0$
9+
--
10+
--
11+
Test that we support enum values and traces for an struct with enums fields. At the time of adding
12+
the regression test, this exercised the conversion code specific to c_enum_tag_typet.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <assert.h>
2+
3+
enum E
4+
{
5+
V0 = 0,
6+
V1 = 1,
7+
V2 = 2
8+
};
9+
10+
int main()
11+
{
12+
enum E e;
13+
e = V1;
14+
__CPROVER_assume(__CPROVER_enum_is_in_range(e));
15+
__CPROVER_assert(e > 10, "Variable e is V1, so this should fail");
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
simple.c
3+
--trace
4+
Passing problem to incremental SMT2 solving
5+
line 15 Variable e is V1, so this should fail: FAILURE
6+
e=/\*enum\*/V0 \(00000000 00000000 00000000 00000000\)
7+
e=/\*enum\*/V1 \(00000000 00000000 00000000 00000001\)
8+
^EXIT=10$
9+
^SIGNAL=0$
10+
--
11+
--
12+
Test that we support enum values and traces for a trivial example. At the
13+
time of adding the regression test, this exercised the conversion code specific
14+
to c_enum_tag_typet.

0 commit comments

Comments
 (0)