1
1
// Author: Diffblue Ltd.
2
2
3
3
#include < util/arith_tools.h>
4
+ #include < util/bitvector_expr.h>
4
5
#include < util/bitvector_types.h>
5
6
#include < util/namespace.h>
6
7
#include < util/symbol_table.h>
@@ -71,9 +72,9 @@ TEST_CASE("struct encoding of types", "[core][smt2_incremental]")
71
72
72
73
TEST_CASE (" struct encoding of expressions" , " [core][smt2_incremental]" )
73
74
{
74
- const struct_union_typet::componentst components {
75
+ const struct_union_typet::componentst component_types {
75
76
{" green" , signedbv_typet{32 }}, {" eggs" , unsignedbv_typet{16 }}};
76
- const struct_typet struct_type{components };
77
+ const struct_typet struct_type{component_types };
77
78
const type_symbolt type_symbol{" my_structt" , struct_type, ID_C};
78
79
auto test = struct_encoding_test_environmentt::make ();
79
80
test.symbol_table .insert (type_symbol);
@@ -92,4 +93,15 @@ TEST_CASE("struct encoding of expressions", "[core][smt2_incremental]")
92
93
const auto bv_equal = equal_exprt{symbol_expr_as_bv, symbol_expr_as_bv};
93
94
REQUIRE (test.struct_encoding .encode (struct_equal) == bv_equal);
94
95
}
96
+ SECTION (" expression for a struct from list of components" )
97
+ {
98
+ const symbolt green_ham{" ham" , signedbv_typet{32 }, ID_C};
99
+ test.symbol_table .insert (green_ham);
100
+ const auto forty_two = from_integer (42 , unsignedbv_typet{16 });
101
+ const exprt::operandst components{green_ham.symbol_expr (), forty_two};
102
+ const struct_exprt struct_expr{components, struct_tag};
103
+ const concatenation_exprt expected_result{
104
+ {green_ham.symbol_expr (), forty_two}, bv_typet{48 }};
105
+ REQUIRE (test.struct_encoding .encode (struct_expr) == expected_result);
106
+ }
95
107
}
0 commit comments