@@ -1000,3 +1000,62 @@ TEST_CASE(
1000
1000
1001
1001
REQUIRE (returned == constant_exprt{" true" , bool_typet{}});
1002
1002
}
1003
+
1004
+ TEST_CASE (
1005
+ " smt2_incremental_decision_proceduret getting value of empty struct" ,
1006
+ " [core][smt2_incremental]" )
1007
+ {
1008
+ auto test = decision_procedure_test_environmentt::make ();
1009
+ const struct_union_typet::componentst component_types{};
1010
+ const type_symbolt type_symbol{" emptyt" , struct_typet{component_types}, ID_C};
1011
+ test.symbol_table .insert (type_symbol);
1012
+ const struct_tag_typet type_reference{type_symbol.name };
1013
+ const symbolt foo{" foo" , type_reference, ID_C};
1014
+ test.symbol_table .insert (foo);
1015
+ const symbolt bar{" bar" , type_reference, ID_C};
1016
+ test.symbol_table .insert (bar);
1017
+
1018
+ INFO (" Sanity checking decision procedure and flushing size definitions" );
1019
+ test.mock_responses .push_front (smt_check_sat_responset{smt_sat_responset{}});
1020
+ CHECK (test.procedure () == decision_proceduret::resultt::D_SATISFIABLE);
1021
+ test.sent_commands .clear ();
1022
+
1023
+ INFO (" Defining an equality over empty structs" );
1024
+ const auto equality_expression =
1025
+ test.procedure .handle (equal_exprt{foo.symbol_expr (), bar.symbol_expr ()});
1026
+ test.procedure .set_to (equality_expression, true );
1027
+ const smt_identifier_termt expected_foo{" foo" , smt_bit_vector_sortt{8 }};
1028
+ const smt_identifier_termt expected_bar{" bar" , smt_bit_vector_sortt{8 }};
1029
+ const smt_identifier_termt expected_handle{" B0" , smt_bool_sortt{}};
1030
+ const smt_termt expected_equality =
1031
+ smt_core_theoryt::equal (expected_foo, expected_bar);
1032
+ const std::vector<smt_commandt> expected_problem_commands{
1033
+ smt_declare_function_commandt{expected_foo, {}},
1034
+ smt_declare_function_commandt{expected_bar, {}},
1035
+ smt_define_function_commandt{" B0" , {}, expected_equality},
1036
+ smt_assert_commandt{expected_equality}};
1037
+ REQUIRE (test.sent_commands == expected_problem_commands);
1038
+ test.sent_commands .clear ();
1039
+
1040
+ INFO (" Ensuring decision procedure is in suitable state for getting output." );
1041
+ const std::vector<smt_commandt> expected_check_commands{
1042
+ smt_check_sat_commandt{}};
1043
+ test.mock_responses .push_front (smt_check_sat_responset{smt_sat_responset{}});
1044
+ REQUIRE (test.procedure () == decision_proceduret::resultt::D_SATISFIABLE);
1045
+ CHECK (test.sent_commands == expected_check_commands);
1046
+ test.sent_commands .clear ();
1047
+
1048
+ INFO (" Getting values involving empty structs." );
1049
+ test.mock_responses .push_front (
1050
+ smt_get_value_responset{{{expected_handle, smt_bool_literal_termt{true }}}});
1051
+ CHECK (test.procedure .get (equality_expression) == true_exprt{});
1052
+ test.mock_responses .push_front (smt_get_value_responset{
1053
+ {{smt_identifier_termt{" foo" , smt_bit_vector_sortt{8 }},
1054
+ smt_bit_vector_constant_termt{0 , 8 }}}});
1055
+ const struct_exprt expected_empty{{}, type_reference};
1056
+ CHECK (test.procedure .get (foo.symbol_expr ()) == expected_empty);
1057
+ const std::vector<smt_commandt> expected_get_commands{
1058
+ smt_get_value_commandt{expected_handle},
1059
+ smt_get_value_commandt{expected_foo}};
1060
+ CHECK (test.sent_commands == expected_get_commands);
1061
+ }
0 commit comments