Skip to content

Commit 838df42

Browse files
committed
Implement error messaging for invalid SMT responses
1 parent ab83cae commit 838df42

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/solvers/smt2_incremental/smt_response_validation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ response_or_errort<smt_responset> validate_smt_response(const irept &parse_tree)
4848
smt_check_sat_responset{smt_unknown_responset{}}};
4949
if(parse_tree.id() == "success")
5050
return response_or_errort<smt_responset>{smt_success_responset{}};
51-
UNIMPLEMENTED;
51+
return response_or_errort<smt_responset>{"Invalid SMT response \"" +
52+
id2string(parse_tree.id()) + "\""};
5253
}

unit/solvers/smt2_incremental/smt_response_validation.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,20 @@ TEST_CASE("Validation of SMT success response", "[core][smt2_incremental]")
5050
*validate_smt_response(*smt2irep("success").parsed_output).get_if_valid() ==
5151
smt_success_responset{});
5252
}
53+
54+
TEST_CASE(
55+
"Error handling of SMT response validation",
56+
"[core][smt2_incremental]")
57+
{
58+
SECTION("Parse tree produced is not a valid SMT-LIB version 2.6 response")
59+
{
60+
const response_or_errort<smt_responset> validation_response =
61+
validate_smt_response(*smt2irep("foobar").parsed_output);
62+
CHECK(
63+
*validation_response.get_if_error() ==
64+
std::vector<std::string>{"Invalid SMT response \"foobar\""});
65+
CHECK(
66+
*validate_smt_response(*smt2irep("()").parsed_output).get_if_error() ==
67+
std::vector<std::string>{"Invalid SMT response \"\""});
68+
}
69+
}

0 commit comments

Comments
 (0)