Skip to content

Commit 44c97b6

Browse files
Fix broken interval unit tests
1 parent 1fbcbf5 commit 44c97b6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

unit/util/interval/multiply.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ SCENARIO("multiply interval domain",
5959

6060
WHEN("One is entirely negative [-2,-5]*[7,11]")
6161
{
62-
constant_interval_exprt a(values[-2], values[-5]);
62+
constant_interval_exprt a(values[-5], values[-2]);
6363
constant_interval_exprt b(values[7], values[11]);
6464

6565
constant_interval_exprt result = a.multiply(b);
6666

6767
THEN("Domain is consistent")
6868
{
69-
CHECK(V(a.get_lower()) == -2);
70-
CHECK(V(a.get_upper()) == -5);
69+
CHECK(V(a.get_lower()) == -5);
70+
CHECK(V(a.get_upper()) == -2);
7171
CHECK(V(b.get_lower()) == 7);
7272
CHECK(V(b.get_upper()) == 11);
7373
}

unit/util/interval/subtract.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,13 @@ SCENARIO("subtract interval domain",
107107

108108
SCENARIO("Subtracting unsigned integers")
109109
{
110+
auto get_value = [](int x) {
111+
return from_integer(x, signedbv_typet(32));
112+
};
113+
110114
WHEN("Subtracting two constant intervals") {
111-
auto lhs = constant_interval_exprt(constant_exprt("1010", unsignedbv_typet(32)));
112-
auto rhs = constant_interval_exprt(constant_exprt("0011", unsignedbv_typet(32)));
115+
auto lhs = constant_interval_exprt(get_value(10));
116+
auto rhs = constant_interval_exprt(get_value(3));
113117
THEN("it should work") {
114118
auto result = lhs.minus(rhs);
115119
REQUIRE(result.is_single_value_interval());
@@ -121,8 +125,8 @@ SCENARIO("Subtracting unsigned integers")
121125

122126
WHEN("Subtracting zero from something")
123127
{
124-
auto lhs = constant_interval_exprt(constant_exprt("1010", unsignedbv_typet(32)));
125-
auto rhs = constant_interval_exprt(constant_exprt("0", unsignedbv_typet(32)));
128+
auto lhs = constant_interval_exprt(get_value(10));
129+
auto rhs = constant_interval_exprt(get_value(0));
126130

127131
THEN("it should not give a completely crazy result")
128132
{
@@ -136,9 +140,8 @@ SCENARIO("Subtracting unsigned integers")
136140

137141
WHEN("Subtracting an non-constant interval containing zero")
138142
{
139-
auto lhs = constant_interval_exprt(constant_exprt("1010", unsignedbv_typet(32)));
140-
auto rhs = constant_interval_exprt(constant_exprt("0", unsignedbv_typet(32)),
141-
constant_exprt("1", unsignedbv_typet(32)));
143+
auto lhs = constant_interval_exprt(get_value(10));
144+
auto rhs = constant_interval_exprt(get_value(0), get_value(1));
142145
THEN("it should not give a completely crazy result")
143146
{
144147
auto result = lhs.minus(rhs);

0 commit comments

Comments
 (0)