11// Author: Diffblue Ltd.
22
33#include < util/arith_tools.h>
4+ #include < util/bitvector_expr.h>
45#include < util/bitvector_types.h>
56#include < util/namespace.h>
67#include < util/symbol_table.h>
@@ -71,9 +72,9 @@ TEST_CASE("struct encoding of types", "[core][smt2_incremental]")
7172
7273TEST_CASE (" struct encoding of expressions" , " [core][smt2_incremental]" )
7374{
74- const struct_union_typet::componentst components {
75+ const struct_union_typet::componentst component_types {
7576 {" green" , signedbv_typet{32 }}, {" eggs" , unsignedbv_typet{16 }}};
76- const struct_typet struct_type{components };
77+ const struct_typet struct_type{component_types };
7778 const type_symbolt type_symbol{" my_structt" , struct_type, ID_C};
7879 auto test = struct_encoding_test_environmentt::make ();
7980 test.symbol_table .insert (type_symbol);
@@ -92,4 +93,15 @@ TEST_CASE("struct encoding of expressions", "[core][smt2_incremental]")
9293 const auto bv_equal = equal_exprt{symbol_expr_as_bv, symbol_expr_as_bv};
9394 REQUIRE (test.struct_encoding .encode (struct_equal) == bv_equal);
9495 }
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+ }
95107}
0 commit comments