1
1
/* ******************************************************************\
2
2
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
5
5
6
6
Author: Diffblue Ltd.
7
7
18
18
SCENARIO (" concretize_array_expression" ,
19
19
" [core][solvers][refinement][string_refinement]" )
20
20
{
21
+ // Arrange
21
22
const typet char_type=unsignedbv_typet (16 );
22
23
const typet int_type=signedbv_typet (32 );
23
24
const exprt index1=from_integer (1 , int_type);
@@ -27,33 +28,31 @@ SCENARIO("concretize_array_expression",
27
28
const exprt index100=from_integer (100 , int_type);
28
29
const exprt char0=from_integer (' 0' , char_type);
29
30
const exprt index2=from_integer (2 , int_type);
31
+ const exprt charz = from_integer (' z' , char_type);
30
32
array_typet array_type (char_type, infinity_exprt (int_type));
31
33
32
34
// 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 (
37
38
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);
58
57
REQUIRE (concrete==expected);
59
58
}
0 commit comments