Skip to content

Commit c59ebf8

Browse files
Stop using concrietize_array_expr in unit tests
We should use sparse arrays as in the solver.
1 parent 6b89e82 commit c59ebf8

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************\
22
3-
Module: Unit tests for concretize_array_expression in
4-
solvers/refinement/string_refinement.cpp
3+
Module: Unit tests for interval_sparse_arrayt::concretizein
4+
solvers/refinement/string_refinement_util.cpp
55
66
Author: Diffblue Ltd.
77
@@ -18,6 +18,7 @@
1818
SCENARIO("concretize_array_expression",
1919
"[core][solvers][refinement][string_refinement]")
2020
{
21+
// Arrange
2122
const typet char_type=unsignedbv_typet(16);
2223
const typet int_type=signedbv_typet(32);
2324
const exprt index1=from_integer(1, int_type);
@@ -27,33 +28,31 @@ SCENARIO("concretize_array_expression",
2728
const exprt index100=from_integer(100, int_type);
2829
const exprt char0=from_integer('0', char_type);
2930
const exprt index2=from_integer(2, int_type);
31+
const exprt charz = from_integer('z', char_type);
3032
array_typet array_type(char_type, infinity_exprt(int_type));
3133

3234
// input_expr is
33-
// `'0' + (ARRAY_OF(0) WITH [1:=x] WITH [4:=y] WITH [100:=z])[2]`
34-
const plus_exprt input_expr(
35-
from_integer('0', char_type),
36-
index_exprt(
35+
// ARRAY_OF(0) WITH [1:=x] WITH [4:=y] WITH [100:=z]`
36+
const with_exprt input_expr(
37+
with_exprt(
3738
with_exprt(
38-
with_exprt(
39-
with_exprt(
40-
array_of_exprt(from_integer(0, char_type), array_type),
41-
index1,
42-
charx),
43-
index4,
44-
chary),
45-
index100,
46-
from_integer('z', char_type)),
47-
index2));
48-
49-
// String max length is 50, so index 100 should get ignored.
50-
symbol_tablet symbol_table;
51-
namespacet ns(symbol_table);
52-
const exprt concrete = concretize_arrays_in_expression(input_expr, 50, ns);
53-
54-
// The expected result is `'0' + { 'x', 'x', 'y', 'y', 'y' }`
55-
array_exprt array(array_type);
56-
array.operands()={charx, charx, chary, chary, chary};
57-
const plus_exprt expected(char0, index_exprt(array, index2));
39+
array_of_exprt(from_integer(0, char_type), array_type),
40+
index1,
41+
charx),
42+
index4,
43+
chary),
44+
index100,
45+
charz);
46+
47+
// Act
48+
const interval_sparse_arrayt sparse_array(input_expr);
49+
// String size is 7, so index 100 should get ignored.
50+
const exprt concrete = sparse_array.concretize(7, int_type);
51+
52+
// Assert
53+
array_exprt expected(array_type);
54+
// The expected result is `{ 'x', 'x', 'y', 'y', 'y', 'z', 'z' }`
55+
expected.operands()={charx, charx, chary, chary, chary, charz, charz};
56+
to_array_type(expected.type()).size() = from_integer(7, int_type);
5857
REQUIRE(concrete==expected);
5958
}

0 commit comments

Comments
 (0)