Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fix and test to term translation #367

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/term_translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ Term TermTranslator::value_from_smt2(const std::string val,
}
}
else if (sk == STRING){
return solver->make_term(val, false, sort);
std::string new_val = val;
if (val.length() > 1 && val.at(0) == '\"') {
new_val = new_val.substr(1,new_val.length()-2);
}
return solver->make_term(new_val, true, sort);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this fix. It looks like it just strips the double-quote character from the front of the string and whatever character is at the end of the string. Shouldn't you check whether the last character is '"' too? And what about escape characters in the middle?

{
throw NotImplementedException(
Expand Down
15 changes: 15 additions & 0 deletions tests/test-term-translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,21 @@ TEST_P(TranslationTests, UninterpretedSort)
EXPECT_EQ(fv, fv_1);
}

TEST_P(TranslationTests, Strings)
{
Sort strsort = s1->make_sort(STRING);
Term t = s1->make_term("\\u{a}", true, strsort);

TermTranslator to_s2(s2);
TermTranslator to_s1(s1);

Term t2 = to_s2.transfer_term(t);
EXPECT_EQ(t2->to_string(), t->to_string());

Term t1 = to_s1.transfer_term(t2);
EXPECT_EQ(t, t1);
}

TEST_P(BoolArrayTranslationTests, Arrays)
{
Term f = s1->make_term(false);
Expand Down
Loading