Skip to content

Commit 3a353a6

Browse files
committed
Extend unit test of extract_bits conversion with integer bounds
Because instances of this expression are constructed using integer bounds rather than bit vector bounds, as part of the left shift overflow checks.
1 parent 79766cb commit 3a353a6

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

unit/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -920,20 +920,34 @@ TEST_CASE(
920920
"[core][smt2_incremental]")
921921
{
922922
const typet operand_type = unsignedbv_typet{8};
923-
const exprt input = extractbits_exprt{
924-
symbol_exprt{"foo", operand_type},
925-
from_integer(4, operand_type),
926-
from_integer(2, operand_type),
927-
unsignedbv_typet{3}};
923+
std::string description;
924+
exprt input;
925+
using rowt = std::pair<std::string, exprt>;
926+
std::tie(description, input) = GENERATE_REF(
927+
rowt{
928+
"Bit vector typed bounds",
929+
extractbits_exprt{
930+
symbol_exprt{"foo", operand_type},
931+
from_integer(4, operand_type),
932+
from_integer(2, operand_type),
933+
unsignedbv_typet{3}}},
934+
rowt{
935+
"Constant integer bounds",
936+
extractbits_exprt{
937+
symbol_exprt{"foo", operand_type}, 4, 2, unsignedbv_typet{3}}});
928938
const smt_termt expected_result = smt_bit_vector_theoryt::extract(4, 2)(
929939
smt_identifier_termt{"foo", smt_bit_vector_sortt{8}});
930-
CHECK(convert_expr_to_smt(input) == expected_result);
931-
const cbmc_invariants_should_throwt invariants_throw;
932-
CHECK_THROWS(convert_expr_to_smt(extractbits_exprt{
933-
symbol_exprt{"foo", operand_type},
934-
symbol_exprt{"bar", operand_type},
935-
symbol_exprt{"bar", operand_type},
936-
unsignedbv_typet{3}}));
940+
SECTION(description)
941+
{
942+
INFO("Input expression - " + input.pretty(1, 0));
943+
CHECK(convert_expr_to_smt(input) == expected_result);
944+
const cbmc_invariants_should_throwt invariants_throw;
945+
CHECK_THROWS(convert_expr_to_smt(extractbits_exprt{
946+
symbol_exprt{"foo", operand_type},
947+
symbol_exprt{"bar", operand_type},
948+
symbol_exprt{"bar", operand_type},
949+
unsignedbv_typet{3}}));
950+
}
937951
}
938952

939953
TEST_CASE("expr to smt conversion for type casts", "[core][smt2_incremental]")

0 commit comments

Comments
 (0)