Skip to content

Commit 10ddca0

Browse files
authored
Merge pull request #6225 from thomasspriggs/tas/unit_test_smt_identifier_conversion
Add unit test of `smt2_convt::convert_identifier`
2 parents 9f19902 + 665eaad commit 10ddca0

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/solvers/smt2/smt2_conv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class smt2_convt : public stack_decision_proceduret
8282

8383
std::size_t get_number_of_solver_calls() const override;
8484

85+
static std::string convert_identifier(const irep_idt &identifier);
86+
8587
protected:
8688
const namespacet &ns;
8789
std::ostream &out;
@@ -136,8 +138,6 @@ class smt2_convt : public stack_decision_proceduret
136138
void convert_with(const with_exprt &expr);
137139
void convert_update(const exprt &expr);
138140

139-
std::string convert_identifier(const irep_idt &identifier);
140-
141141
void convert_expr(const exprt &);
142142
void convert_type(const typet &);
143143
void convert_literal(const literalt);

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ SRC += analyses/ai/ai.cpp \
8484
solvers/sat/external_sat.cpp \
8585
solvers/sat/satcheck_cadical.cpp \
8686
solvers/sat/satcheck_minisat2.cpp \
87+
solvers/smt2/smt2_conv.cpp \
8788
solvers/strings/array_pool/array_pool.cpp \
8889
solvers/strings/string_constraint_generator_valueof/calculate_max_string_length.cpp \
8990
solvers/strings/string_constraint_generator_valueof/get_numeric_value_from_character.cpp \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
solvers/smt2
2+
testing-utils

unit/solvers/smt2/smt2_conv.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Author: Diffblue Ltd.
2+
3+
#include <testing-utils/use_catch.h>
4+
5+
#include <solvers/smt2/smt2_conv.h>
6+
7+
TEST_CASE(
8+
"smt2_convt::convert_identifier character escaping.",
9+
"[core][solvers][smt2]")
10+
{
11+
const auto no_escaping_characters = "abcdefghijklmnopqrstuvwxyz0123456789$";
12+
CHECK(
13+
smt2_convt::convert_identifier(no_escaping_characters) ==
14+
no_escaping_characters);
15+
CHECK(smt2_convt::convert_identifier("\\") == "&92;");
16+
CHECK(smt2_convt::convert_identifier("|") == "&124;");
17+
CHECK(smt2_convt::convert_identifier("&") == "&38;");
18+
}

0 commit comments

Comments
 (0)