Skip to content

Commit 42e2d5a

Browse files
author
Thomas Kiley
committed
Tidy the test for unary minus
1 parent 7f61939 commit 42e2d5a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

unit/util/interval/eval.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,14 @@ SCENARIO("Unary eval on intervals", "[core][analyses][interval][eval]")
8383
REQUIRE(five_to_eight.eval(ID_unary_plus) == five_to_eight);
8484
}
8585

86-
THEN("When we apply unary subtraction to it, it should be negated")
86+
THEN("When we apply unary minus to it, it should be negated")
8787
{
88-
auto negated_val = numeric_cast<mp_integer>(
89-
five_to_eight.eval(ID_unary_minus).get_lower());
90-
REQUIRE(negated_val.has_value());
91-
REQUIRE(negated_val.value() == -8);
92-
93-
auto upper_value = numeric_cast<mp_integer>(
94-
five_to_eight.eval(ID_unary_minus).get_upper());
95-
REQUIRE(upper_value.has_value());
96-
REQUIRE(upper_value.value() == -5);
88+
const constant_interval_exprt &negated_value =
89+
five_to_eight.eval(ID_unary_minus);
90+
REQUIRE(
91+
negated_value ==
92+
constant_interval_exprt{from_integer(-8, signedbv_typet(32)),
93+
from_integer(-5, signedbv_typet(32))});
9794
}
9895

9996
THEN("When we apply bitwise negation to it, is should be bitwise negated")

0 commit comments

Comments
 (0)