File: xml_expr.cpp

package info (click to toggle)
cbmc 6.6.0-4
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 153,852 kB
  • sloc: cpp: 386,459; ansic: 114,466; java: 28,405; python: 6,003; yacc: 4,552; makefile: 4,041; lex: 2,487; xml: 2,388; sh: 2,050; perl: 557; pascal: 184; javascript: 163; ada: 36
file content (39 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************************\

Module: Unit tests of expression to xmlt conversion

Author: Michael Tautschnig

\*******************************************************************/

#include <testing-utils/use_catch.h>

#include <util/arith_tools.h>
#include <util/bitvector_types.h>
#include <util/config.h>
#include <util/namespace.h>
#include <util/symbol_table.h>

#include <goto-programs/xml_expr.h>

TEST_CASE("Constant expression to XML")
{
  config.set_arch("none");

  const symbol_tablet symbol_table;
  const namespacet ns(symbol_table);

  const constant_exprt number_ubv = from_integer(0xFF, unsignedbv_typet(8));
  const xmlt x_ubv = xml(number_ubv, ns);

  REQUIRE(x_ubv.get_attribute("binary") == "11111111");

  fixedbv_typet fixedbv_type;
  fixedbv_type.set_width(8);
  fixedbv_type.set_integer_bits(6);

  const constant_exprt number_fbv = from_integer(0x3, fixedbv_type);
  const xmlt x_fbv = xml(number_fbv, ns);

  REQUIRE(x_fbv.get_attribute("binary") == "00001100");
}