Skip to content

Commit 177a431

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
More regression tests
For unions, array, and pointers to both.
1 parent 0c31a7f commit 177a431

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <assert.h>
2+
3+
int array[] = {1, 2, 3};
4+
int *p;
5+
int *q;
6+
7+
void initialize()
8+
{
9+
p = &(array[1]);
10+
q = array + 1;
11+
array[0] = 4;
12+
}
13+
14+
void checkpoint()
15+
{
16+
}
17+
18+
int main()
19+
{
20+
initialize();
21+
checkpoint();
22+
23+
assert(p == &(array[1]));
24+
assert(p == q);
25+
assert(*p == *q);
26+
assert(array[0] != *p);
27+
*p = 4;
28+
assert(array[0] == *p);
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
main.c
3+
array,p,q --harness-type initialise-with-memory-snapshot --initial-location main:4
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line [0-9]+ assertion p == \&\(array\[1\]\): SUCCESS
7+
\[main.assertion.2\] line [0-9]+ assertion p == q: SUCCESS
8+
\[main.assertion.3\] line [0-9]+ assertion \*p == \*q: SUCCESS
9+
\[main.assertion.4\] line [0-9]+ assertion array\[0\] != \*p: SUCCESS
10+
\[main.assertion.5\] line [0-9]+ assertion array\[0\] == \*p: SUCCESS
11+
VERIFICATION SUCCESSFUL
12+
--
13+
^warning: ignoring
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <assert.h>
2+
3+
union Un {
4+
int i;
5+
float f;
6+
} un;
7+
8+
int *ip;
9+
float *fp;
10+
11+
void initialize()
12+
{
13+
un.i = 1;
14+
ip = &un.i;
15+
fp = &un.f;
16+
}
17+
18+
void checkpoint()
19+
{
20+
}
21+
22+
int main()
23+
{
24+
initialize();
25+
checkpoint();
26+
27+
assert(ip == &un.i);
28+
assert(*ip == un.i);
29+
*fp = 2.0f;
30+
assert(un.f == 2.0f);
31+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
un,ip,fp --harness-type initialise-with-memory-snapshot --initial-location main:4
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
\[main.assertion.1\] line [0-9]+ assertion ip == \&un.i: SUCCESS
7+
\[main.assertion.2\] line [0-9]+ assertion \*ip == un.i: SUCCESS
8+
\[main.assertion.3\] line [0-9]+ assertion un.f == 2.0f: SUCCESS
9+
VERIFICATION SUCCESSFUL
10+
--
11+
^warning: ignoring

0 commit comments

Comments
 (0)