File tree 3 files changed +40
-1
lines changed
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,8 @@ bool exprt::is_zero() const
178
178
}
179
179
else if (type_id==ID_unsignedbv ||
180
180
type_id==ID_signedbv ||
181
- type_id==ID_c_bool)
181
+ type_id==ID_c_bool ||
182
+ type_id==ID_c_bit_field)
182
183
{
183
184
return constant.value_is_zero_string ();
184
185
}
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/expr.h>
12
+ #include < util/std_types.h>
13
+ #include < util/std_expr.h>
14
+ #include < util/arith_tools.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 = from_integer (mp_integer (3 ), c_bit_field_typet (signedbv_typet (32 ), 4 ));
22
+
23
+ THEN (" is_zero() should be false" )
24
+ {
25
+ REQUIRE (!bitfield3.is_zero ());
26
+ }
27
+ }
28
+ GIVEN (" An exprt representing a bitfield constant of 0" )
29
+ {
30
+ const exprt bitfield0 = from_integer (mp_integer (0 ), c_bit_field_typet (signedbv_typet (32 ), 4 ));
31
+
32
+ THEN (" is_zero() should be true" )
33
+ {
34
+ REQUIRE (bitfield0.is_zero ());
35
+ }
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments