Skip to content

Commit d4bfc9c

Browse files
committed
Change tests to reflect new reality around quoting symbols.
1 parent 8112492 commit d4bfc9c

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed

unit/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,29 @@
1111
#include <solvers/smt2_incremental/smt_to_smt2_string.h>
1212
#include <testing-utils/use_catch.h>
1313

14+
#include <tuple>
15+
1416
TEST_CASE("Test smt_indext to string conversion", "[core][smt2_incremental]")
1517
{
16-
CHECK(smt_to_smt2_string(smt_symbol_indext{"green"}) == "|green|");
18+
std::string input_term;
19+
std::string expected_term;
20+
using rowt = std::pair<std::string, std::string>;
21+
22+
std::tie(input_term, expected_term) = GENERATE(
23+
rowt{"green", "green"},
24+
rowt{"abc76473*^&", "abc76473*^&"},
25+
rowt{"my name is", "|my name is|"},
26+
// The following are example symbols from the SMTLIB spec.
27+
rowt{"+", "+"},
28+
rowt{"**", "**"},
29+
rowt{".kkk", ".kkk"},
30+
rowt{"-32", "-32"},
31+
rowt{" \" can occur too", "| \" can occur too|"});
32+
33+
SECTION("check that index identifiers are constructed accordingly")
34+
{
35+
CHECK(smt_to_smt2_string(smt_symbol_indext{input_term}) == expected_term);
36+
}
1737
CHECK(smt_to_smt2_string(smt_numeral_indext{42}) == "42");
1838
}
1939

@@ -36,7 +56,7 @@ TEST_CASE(
3656
{
3757
CHECK(
3858
smt_to_smt2_string(smt_bit_vector_theoryt::extract(7, 3)(
39-
smt_bit_vector_constant_termt{0, 8})) == "((_ |extract| 7 3) (_ bv0 8))");
59+
smt_bit_vector_constant_termt{0, 8})) == "((_ extract 7 3) (_ bv0 8))");
4060
}
4161

4262
TEST_CASE(
@@ -51,23 +71,38 @@ TEST_CASE(
5171
"Test smt_identifier_termt to string conversion",
5272
"[core][smt2_incremental]")
5373
{
74+
std::string input_term;
75+
std::string expected_term;
76+
using rowt = std::pair<std::string, std::string>;
77+
78+
std::tie(input_term, expected_term) = GENERATE(
79+
rowt{"abc", "abc"},
80+
rowt{"\\", "|&92;|"},
81+
rowt{"green", "green"},
82+
rowt{"abc76473*^&", "abc76473*^&"},
83+
rowt{"my name is", "|my name is|"},
84+
// The following are example symbols from the SMTLIB spec.
85+
rowt{"+", "+"},
86+
rowt{"**", "**"},
87+
rowt{".kkk", ".kkk"},
88+
rowt{"-32", "-32"},
89+
rowt{" \" can occur too", "| \" can occur too|"});
90+
5491
SECTION("Simple identifiers")
5592
{
5693
CHECK(
57-
smt_to_smt2_string(smt_identifier_termt{"abc", smt_bool_sortt{}}) ==
58-
"|abc|");
59-
CHECK(
60-
smt_to_smt2_string(smt_identifier_termt{"\\", smt_bool_sortt{}}) ==
61-
"|&92;|");
94+
smt_to_smt2_string(smt_identifier_termt{input_term, smt_bool_sortt{}}) ==
95+
expected_term);
6296
}
97+
6398
SECTION("Indexed identifier")
6499
{
65100
CHECK(
66101
smt_to_smt2_string(smt_identifier_termt{
67102
"foo",
68103
smt_bool_sortt{},
69104
{smt_symbol_indext{"bar"}, smt_numeral_indext{42}}}) ==
70-
"(_ |foo| |bar| 42)");
105+
"(_ foo bar 42)");
71106
}
72107
}
73108

@@ -78,8 +113,7 @@ TEST_CASE(
78113
CHECK(
79114
smt_to_smt2_string(smt_core_theoryt::equal(
80115
smt_identifier_termt{"foo", smt_bit_vector_sortt{32}},
81-
smt_identifier_termt{"bar", smt_bit_vector_sortt{32}})) ==
82-
"(|=| |foo| |bar|)");
116+
smt_identifier_termt{"bar", smt_bit_vector_sortt{32}})) == "(= foo bar)");
83117
}
84118

85119
TEST_CASE(
@@ -102,7 +136,7 @@ TEST_CASE(
102136
{
103137
CHECK(
104138
smt_to_smt2_string(smt_get_value_commandt{
105-
smt_identifier_termt{"foo", smt_bool_sortt{}}}) == "(get-value (|foo|))");
139+
smt_identifier_termt{"foo", smt_bool_sortt{}}}) == "(get-value (foo))");
106140
}
107141

108142
TEST_CASE(
@@ -138,7 +172,7 @@ TEST_CASE(
138172
smt_to_smt2_string(smt_declare_function_commandt{
139173
smt_identifier_termt{"f", smt_bit_vector_sortt{31}},
140174
{smt_bit_vector_sortt{32}, smt_bit_vector_sortt{33}}}) ==
141-
"(declare-fun |f| ((_ BitVec 32) (_ BitVec 33)) (_ BitVec 31))");
175+
"(declare-fun f ((_ BitVec 32) (_ BitVec 33)) (_ BitVec 31))");
142176
}
143177

144178
TEST_CASE(
@@ -151,8 +185,7 @@ TEST_CASE(
151185
CHECK(
152186
smt_to_smt2_string(smt_define_function_commandt{
153187
"f", {g, h}, smt_core_theoryt::equal(g, h)}) ==
154-
"(define-fun |f| ((|g| (_ BitVec 32)) (|h| (_ BitVec 32))) Bool (|=| |g| "
155-
"|h|))");
188+
"(define-fun f ((g (_ BitVec 32)) (h (_ BitVec 32))) Bool (= g h))");
156189
}
157190

158191
TEST_CASE(

0 commit comments

Comments
 (0)