|
14 | 14 |
|
15 | 15 | #include <solvers/smt2_incremental/convert_expr_to_smt.h> |
16 | 16 | #include <solvers/smt2_incremental/object_tracking.h> |
| 17 | +#include <solvers/smt2_incremental/smt_array_theory.h> |
17 | 18 | #include <solvers/smt2_incremental/smt_bit_vector_theory.h> |
18 | 19 | #include <solvers/smt2_incremental/smt_core_theory.h> |
19 | 20 | #include <solvers/smt2_incremental/smt_terms.h> |
@@ -96,6 +97,20 @@ expr_to_smt_conversion_test_environmentt::convert(const exprt &expression) const |
96 | 97 | object_size_function.make_application); |
97 | 98 | } |
98 | 99 |
|
| 100 | +TEST_CASE("\"array_typet\" to smt sort conversion", "[core][smt2_incremental]") |
| 101 | +{ |
| 102 | + auto test = |
| 103 | + expr_to_smt_conversion_test_environmentt::make(test_archt::x86_64); |
| 104 | + |
| 105 | + const auto array_type = |
| 106 | + array_typet{signedbv_typet{8}, from_integer(8, c_index_type())}; |
| 107 | + INFO("Type being converted: " + array_type.pretty(2, 0)); |
| 108 | + const auto conversion_result = convert_type_to_smt_sort(array_type); |
| 109 | + CHECK( |
| 110 | + conversion_result == |
| 111 | + smt_array_sortt{smt_bit_vector_sortt{64}, smt_bit_vector_sortt{8}}); |
| 112 | +} |
| 113 | + |
99 | 114 | TEST_CASE("\"symbol_exprt\" to smt term conversion", "[core][smt2_incremental]") |
100 | 115 | { |
101 | 116 | auto test = expr_to_smt_conversion_test_environmentt::make(test_archt::i386); |
@@ -1126,6 +1141,52 @@ TEST_CASE( |
1126 | 1141 | } |
1127 | 1142 | } |
1128 | 1143 |
|
| 1144 | +TEST_CASE( |
| 1145 | + "expr to smt conversion for index_exprt expressions", |
| 1146 | + "[core][smt2_incremental]") |
| 1147 | +{ |
| 1148 | + auto test = |
| 1149 | + expr_to_smt_conversion_test_environmentt::make(test_archt::x86_64); |
| 1150 | + const typet value_type = signedbv_typet{8}; |
| 1151 | + const exprt array = symbol_exprt{ |
| 1152 | + "my_array", array_typet{value_type, from_integer(10, signed_size_type())}}; |
| 1153 | + const exprt index = from_integer(42, unsignedbv_typet{64}); |
| 1154 | + const index_exprt index_expr{array, index}; |
| 1155 | + INFO("Expression being converted: " + index_expr.pretty(2, 0)); |
| 1156 | + const smt_termt expected = smt_array_theoryt::select( |
| 1157 | + smt_identifier_termt{ |
| 1158 | + "my_array", |
| 1159 | + smt_array_sortt{smt_bit_vector_sortt{64}, smt_bit_vector_sortt{8}}}, |
| 1160 | + smt_bit_vector_constant_termt{42, 64}); |
| 1161 | + CHECK(test.convert(index_expr) == expected); |
| 1162 | +} |
| 1163 | + |
| 1164 | +TEST_CASE( |
| 1165 | + "expr to smt conversion for with_exprt expressions", |
| 1166 | + "[core][smt2_incremental]") |
| 1167 | +{ |
| 1168 | + auto test = |
| 1169 | + expr_to_smt_conversion_test_environmentt::make(test_archt::x86_64); |
| 1170 | + SECTION("Array types") |
| 1171 | + { |
| 1172 | + const typet value_type = signedbv_typet{8}; |
| 1173 | + const exprt array = symbol_exprt{ |
| 1174 | + "my_array", |
| 1175 | + array_typet{value_type, from_integer(10, signed_size_type())}}; |
| 1176 | + const exprt index = from_integer(42, unsignedbv_typet{64}); |
| 1177 | + const exprt value = from_integer(12, value_type); |
| 1178 | + const with_exprt with{array, index, value}; |
| 1179 | + INFO("Expression being converted: " + with.pretty(2, 0)); |
| 1180 | + const smt_termt expected = smt_array_theoryt::store( |
| 1181 | + smt_identifier_termt{ |
| 1182 | + "my_array", |
| 1183 | + smt_array_sortt{smt_bit_vector_sortt{64}, smt_bit_vector_sortt{8}}}, |
| 1184 | + smt_bit_vector_constant_termt{42, 64}, |
| 1185 | + smt_bit_vector_constant_termt{12, 8}); |
| 1186 | + CHECK(test.convert(with) == expected); |
| 1187 | + } |
| 1188 | +} |
| 1189 | + |
1129 | 1190 | TEST_CASE( |
1130 | 1191 | "expr to smt conversion for extract bits expressions", |
1131 | 1192 | "[core][smt2_incremental]") |
|
0 commit comments