File tree 3 files changed +43
-3
lines changed
3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -176,9 +176,9 @@ bool exprt::is_zero() const
176
176
CHECK_RETURN (false );
177
177
return rat_value.is_zero ();
178
178
}
179
- else if (type_id==ID_unsignedbv ||
180
- type_id== ID_signedbv ||
181
- type_id==ID_c_bool )
179
+ else if (
180
+ type_id == ID_unsignedbv || type_id == ID_signedbv ||
181
+ type_id == ID_c_bool || type_id == ID_c_bit_field )
182
182
{
183
183
return constant.value_is_zero_string ();
184
184
}
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ SRC += unit_tests.cpp \
24
24
solvers/refinement/string_refinement/substitute_array_list.cpp \
25
25
solvers/refinement/string_refinement/sparse_array.cpp \
26
26
solvers/refinement/string_refinement/union_find_replace.cpp \
27
+ util/expr.cpp \
27
28
util/expr_cast/expr_cast.cpp \
28
29
util/graph.cpp \
29
30
util/irep.cpp \
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: Unit test for expr.h/expr.cpp
4
+
5
+ Author: Diffblue Ltd
6
+
7
+ \*******************************************************************/
8
+
9
+ #include < testing-utils/catch.hpp>
10
+
11
+ #include < util/arith_tools.h>
12
+ #include < util/expr.h>
13
+ #include < util/std_expr.h>
14
+ #include < util/std_types.h>
15
+
16
+
17
+ SCENARIO (" bitfield-expr-is-zero" , " [core][util][expr]" )
18
+ {
19
+ GIVEN (" An exprt representing a bitfield constant of 3" )
20
+ {
21
+ const exprt bitfield3 =
22
+ from_integer (mp_integer (3 ), c_bit_field_typet (signedbv_typet (32 ), 4 ));
23
+
24
+ THEN (" is_zero() should be false" )
25
+ {
26
+ REQUIRE_FALSE (bitfield3.is_zero ());
27
+ }
28
+ }
29
+ GIVEN (" An exprt representing a bitfield constant of 0" )
30
+ {
31
+ const exprt bitfield0 =
32
+ from_integer (mp_integer (0 ), c_bit_field_typet (signedbv_typet (32 ), 4 ));
33
+
34
+ THEN (" is_zero() should be true" )
35
+ {
36
+ REQUIRE (bitfield0.is_zero ());
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments