|
32 | 32 | #include <goto-symex/path_storage.h> |
33 | 33 | #include <solvers/smt2_incremental/smt_to_smt2_string.h> |
34 | 34 |
|
| 35 | +#include <algorithm> |
35 | 36 | #include <deque> |
36 | 37 |
|
37 | 38 | class analysis_execption_with_messaget |
@@ -480,22 +481,12 @@ TEST_CASE( |
480 | 481 | std::vector<smt_commandt> expected_commands{ |
481 | 482 | smt_declare_function_commandt{foo_term, {}}, |
482 | 483 | smt_assert_commandt{smt_core_theoryt::equal(foo_term, term_42)}, |
483 | | - invalid_pointer_object_size_definition, |
484 | 484 | null_object_size_definition, |
485 | 485 | null_object_dynamic_definition, |
| 486 | + invalid_pointer_object_size_definition, |
486 | 487 | invalid_pointer_object_dynamic_definition, |
487 | 488 | smt_check_sat_commandt{}}; |
488 | | - REQUIRE( |
489 | | - (test.sent_commands.size() == expected_commands.size() && |
490 | | - std::all_of( |
491 | | - expected_commands.begin(), |
492 | | - expected_commands.end(), |
493 | | - [&](const smt_commandt &command) -> bool { |
494 | | - return std::find( |
495 | | - test.sent_commands.begin(), |
496 | | - test.sent_commands.end(), |
497 | | - command) != test.sent_commands.end(); |
498 | | - }))); |
| 489 | + REQUIRE(test.sent_commands == expected_commands); |
499 | 490 | SECTION("Get \"foo\" value back") |
500 | 491 | { |
501 | 492 | test.sent_commands.clear(); |
@@ -730,6 +721,58 @@ TEST_CASE( |
730 | 721 | REQUIRE(test.sent_commands == expected_commands); |
731 | 722 | } |
732 | 723 |
|
| 724 | +TEST_CASE( |
| 725 | + "smt2_incremental_decision_proceduret defines object properties in order " |
| 726 | + "of object identifiers.", |
| 727 | + "[core][smt2_incremental]") |
| 728 | +{ |
| 729 | + auto test = decision_procedure_test_environmentt::make(); |
| 730 | + // Objects of distinct sizes, so that their definitions can be told apart. |
| 731 | + const symbolt a = make_test_symbol("a", signedbv_typet{8}); |
| 732 | + const symbolt b = make_test_symbol("b", signedbv_typet{16}); |
| 733 | + const symbolt c = make_test_symbol("c", signedbv_typet{32}); |
| 734 | + const pointer_typet pointer_type{signedbv_typet{8}, 32}; |
| 735 | + const auto address = [&](const symbolt &symbol) |
| 736 | + { |
| 737 | + return typecast_exprt::conditional_cast( |
| 738 | + address_of_exprt{symbol.symbol_expr()}, pointer_type); |
| 739 | + }; |
| 740 | + test.procedure.set_to( |
| 741 | + or_exprt{ |
| 742 | + equal_exprt{address(a), address(b)}, equal_exprt{address(b), address(c)}}, |
| 743 | + false); |
| 744 | + test.sent_commands.clear(); |
| 745 | + test.mock_responses.push_back(smt_check_sat_responset{smt_sat_responset{}}); |
| 746 | + test.procedure(); |
| 747 | + |
| 748 | + // Following the null and invalid-pointer objects (identifiers 0 and 1), the |
| 749 | + // objects are identified in the (deterministic) order in which object |
| 750 | + // tracking encounters them, which is c, b, a for this expression. Their |
| 751 | + // properties must be defined in the order of their identifiers, |
| 752 | + // irrespective of the hash values of the objects' base expressions. |
| 753 | + std::vector<smt_commandt> expected_definitions; |
| 754 | + const std::vector<std::size_t> object_sizes{0, 0, 4, 2, 1}; |
| 755 | + for(std::size_t id = 0; id < object_sizes.size(); ++id) |
| 756 | + { |
| 757 | + expected_definitions.push_back(test.object_size_function.make_definition( |
| 758 | + id, smt_bit_vector_constant_termt{object_sizes[id], 32})); |
| 759 | + expected_definitions.push_back( |
| 760 | + test.is_dynamic_object_function.make_definition(id, false)); |
| 761 | + } |
| 762 | + std::vector<smt_commandt> sent_definitions; |
| 763 | + for(const auto &command : test.sent_commands) |
| 764 | + { |
| 765 | + if( |
| 766 | + std::find( |
| 767 | + expected_definitions.begin(), expected_definitions.end(), command) != |
| 768 | + expected_definitions.end()) |
| 769 | + { |
| 770 | + sent_definitions.push_back(command); |
| 771 | + } |
| 772 | + } |
| 773 | + REQUIRE(sent_definitions == expected_definitions); |
| 774 | +} |
| 775 | + |
733 | 776 | TEST_CASE( |
734 | 777 | "smt2_incremental_decision_proceduret function pointer support.", |
735 | 778 | "[core][smt2_incremental]") |
|
0 commit comments