Skip to content

Commit e35425e

Browse files
committed
Add test covering size of two differently sized arrays
1 parent 443d4f0 commit e35425e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
int main()
2+
{
3+
int example_array1[10000];
4+
char example_array2[20000];
5+
void *foo;
6+
__CPROVER_bool choice = nondet___CPROVER_bool();
7+
if(choice)
8+
foo = example_array1;
9+
else
10+
foo = example_array2;
11+
__CPROVER_assert(foo != example_array1 || __CPROVER_OBJECT_SIZE(foo) == 40000, "Array condition 1");
12+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 40000, "Array condition 2");
13+
__CPROVER_assert(foo != example_array2 || __CPROVER_OBJECT_SIZE(foo) == 20000, "Array condition 3");
14+
__CPROVER_assert(__CPROVER_OBJECT_SIZE(foo) == 20000, "Array condition 4");
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
address_of_two_array_sizes.c
3+
--verbosity 10
4+
Passing problem to incremental SMT2 solving
5+
address_of\(main\:\:1\:\:example_array1\!0\@1\[0\]\)
6+
address_of\(main\:\:1\:\:example_array2\!0\@1\[0\]\)
7+
line \d+ Array condition 1: SUCCESS
8+
line \d+ Array condition 2: FAILURE
9+
line \d+ Array condition 3: SUCCESS
10+
line \d+ Array condition 4: FAILURE
11+
^EXIT=10$
12+
^SIGNAL=0$
13+
--
14+
--
15+
Test that __CPROVER_OBJECT_SIZE returns the expected results in the case where
16+
the pointer passed to it may point to one of 2 arrays, where each array has a
17+
different size.

0 commit comments

Comments
 (0)