Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/util/format_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,16 @@
{
// These do not have a numerical interpretation.
// We'll print the 0/1 bit pattern, starting with the bit
// that has the highest index.
// that has the highest index. We use vector notation
// [...] to avoid confusion with decimal numbers.

Check warning on line 194 in src/util/format_expr.cpp

View check run for this annotation

Codecov / codecov/patch

src/util/format_expr.cpp#L194

Added line #L194 was not covered by tests
auto width = to_bv_type(src.type()).get_width();
std::string result;
result.reserve(width);
result.reserve(width + 2);
auto &value = src.get_value();
result += '[';
for(std::size_t i = 0; i < width; i++)
result += get_bvrep_bit(value, width, width - i - 1) ? '1' : '0';
result += ']';
return os << result;
}
else if(type == ID_integer || type == ID_natural || type == ID_range)
Expand Down
2 changes: 1 addition & 1 deletion unit/util/format_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ TEST_CASE("Format a bv-typed constant", "[core][util][format_expr]")
{
auto value = make_bvrep(4, [](std::size_t index) { return index != 2; });
auto expr = constant_exprt{value, bv_typet{4}};
REQUIRE(format_to_string(expr) == "1011");
REQUIRE(format_to_string(expr) == "[1011]");
}
Loading