11
11
#include < solvers/smt2_incremental/smt_to_smt2_string.h>
12
12
#include < testing-utils/use_catch.h>
13
13
14
+ #include < tuple>
15
+
14
16
TEST_CASE (" Test smt_indext to string conversion" , " [core][smt2_incremental]" )
15
17
{
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
+ }
17
37
CHECK (smt_to_smt2_string (smt_numeral_indext{42 }) == " 42" );
18
38
}
19
39
@@ -36,7 +56,7 @@ TEST_CASE(
36
56
{
37
57
CHECK (
38
58
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))" );
40
60
}
41
61
42
62
TEST_CASE (
@@ -51,23 +71,38 @@ TEST_CASE(
51
71
" Test smt_identifier_termt to string conversion" ,
52
72
" [core][smt2_incremental]" )
53
73
{
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
+
54
91
SECTION (" Simple identifiers" )
55
92
{
56
93
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);
62
96
}
97
+
63
98
SECTION (" Indexed identifier" )
64
99
{
65
100
CHECK (
66
101
smt_to_smt2_string (smt_identifier_termt{
67
102
" foo" ,
68
103
smt_bool_sortt{},
69
104
{smt_symbol_indext{" bar" }, smt_numeral_indext{42 }}}) ==
70
- " (_ | foo| | bar| 42)" );
105
+ " (_ foo bar 42)" );
71
106
}
72
107
}
73
108
@@ -78,8 +113,7 @@ TEST_CASE(
78
113
CHECK (
79
114
smt_to_smt2_string (smt_core_theoryt::equal (
80
115
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)" );
83
117
}
84
118
85
119
TEST_CASE (
@@ -102,7 +136,7 @@ TEST_CASE(
102
136
{
103
137
CHECK (
104
138
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))" );
106
140
}
107
141
108
142
TEST_CASE (
@@ -138,7 +172,7 @@ TEST_CASE(
138
172
smt_to_smt2_string (smt_declare_function_commandt{
139
173
smt_identifier_termt{" f" , smt_bit_vector_sortt{31 }},
140
174
{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))" );
142
176
}
143
177
144
178
TEST_CASE (
@@ -151,8 +185,7 @@ TEST_CASE(
151
185
CHECK (
152
186
smt_to_smt2_string (smt_define_function_commandt{
153
187
" 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))" );
156
189
}
157
190
158
191
TEST_CASE (
0 commit comments