File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,8 @@ xmlt xml(
164
164
std::size_t width=to_bitvector_type (type).get_width ();
165
165
166
166
result.name =" integer" ;
167
- result.set_attribute (" binary " ,
168
- id2string ( to_constant_expr (expr). get_value () ));
167
+ result.set_attribute (
168
+ " binary " , integer2binary (numeric_cast_v<mp_integer> (expr), width ));
169
169
result.set_attribute (" width" , width);
170
170
171
171
const typet &underlying_type = type.id () == ID_c_bit_field
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ SRC += analyses/ai/ai.cpp \
65
65
util/symbol_table.cpp \
66
66
util/symbol.cpp \
67
67
util/unicode.cpp \
68
+ util/xml_expr.cpp \
68
69
# Empty last line
69
70
70
71
INCLUDES = -I ../src/ -I.
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: Unit tests of expression to xmlt conversion
4
+
5
+ Author: Michael Tautschnig
6
+
7
+ \*******************************************************************/
8
+
9
+ #include < testing-utils/catch.hpp>
10
+
11
+ #include < util/arith_tools.h>
12
+ #include < util/config.h>
13
+ #include < util/namespace.h>
14
+ #include < util/std_expr.h>
15
+ #include < util/symbol_table.h>
16
+ #include < util/xml_expr.h>
17
+
18
+ TEST_CASE (" Constant expression to XML" )
19
+ {
20
+ config.set_arch (" none" );
21
+
22
+ const symbol_tablet symbol_table;
23
+ const namespacet ns (symbol_table);
24
+
25
+ const constant_exprt number = from_integer (0xFF , unsignedbv_typet (8 ));
26
+ const xmlt x = xml (number, ns);
27
+
28
+ REQUIRE (x.get_attribute (" binary" ) == " 11111111" );
29
+ }
You can’t perform that action at this time.
0 commit comments