@@ -113,7 +113,8 @@ TEST_CASE(
113
113
const cbmc_invariants_should_throwt invariants_throw;
114
114
115
115
REQUIRE_THROWS_MATCHES (
116
- duplicate_per_byte (array_of_exprt{true_exprt{}, array_type}, input_type),
116
+ duplicate_per_byte (
117
+ array_of_exprt{true_exprt{}, array_type}, input_type, test.ns ),
117
118
invariant_failedt,
118
119
invariant_failure_containing (
119
120
" Condition: (init_type_as_bitvector && "
@@ -128,7 +129,8 @@ TEST_CASE(
128
129
const cbmc_invariants_should_throwt invariants_throw;
129
130
130
131
REQUIRE_THROWS_MATCHES (
131
- duplicate_per_byte (from_integer (0 , unsignedbv_typet{10 }), input_type),
132
+ duplicate_per_byte (
133
+ from_integer (0 , unsignedbv_typet{10 }), input_type, test.ns ),
132
134
invariant_failedt,
133
135
invariant_failure_containing (
134
136
" init_type_as_bitvector->get_width() <= config.ansi_c.char_width" ));
@@ -170,15 +172,17 @@ TEST_CASE(
170
172
typet output_type = unsignedbv_typet{output_size};
171
173
const auto result = duplicate_per_byte (
172
174
from_integer (init_expr_value, unsignedbv_typet{init_expr_size}),
173
- output_type);
175
+ output_type,
176
+ test.ns );
174
177
const auto expected =
175
178
from_integer (output_expected_value, unsignedbv_typet{output_size});
176
179
REQUIRE (result == expected);
177
180
178
181
// Check that signed-bv values are replicated including the sign bit.
179
182
const auto result_with_signed_init_type = duplicate_per_byte (
180
183
from_integer (init_expr_value, signedbv_typet{init_expr_size}),
181
- output_type);
184
+ output_type,
185
+ test.ns );
182
186
REQUIRE (result_with_signed_init_type == result);
183
187
}
184
188
@@ -187,15 +191,17 @@ TEST_CASE(
187
191
typet output_type = signedbv_typet{output_size};
188
192
const auto result = duplicate_per_byte (
189
193
from_integer (init_expr_value, unsignedbv_typet{init_expr_size}),
190
- output_type);
194
+ output_type,
195
+ test.ns );
191
196
const auto expected =
192
197
from_integer (output_expected_value, signedbv_typet{output_size});
193
198
REQUIRE (result == expected);
194
199
195
200
// Check that signed-bv values are replicated including the sign bit.
196
201
const auto result_with_signed_init_type = duplicate_per_byte (
197
202
from_integer (init_expr_value, signedbv_typet{init_expr_size}),
198
- output_type);
203
+ output_type,
204
+ test.ns );
199
205
REQUIRE (result_with_signed_init_type == result);
200
206
}
201
207
@@ -205,7 +211,8 @@ TEST_CASE(
205
211
const pointer_typet output_type{bool_typet{}, output_size};
206
212
const auto result = duplicate_per_byte (
207
213
from_integer (init_expr_value, signedbv_typet{init_expr_size}),
208
- output_type);
214
+ output_type,
215
+ test.ns );
209
216
auto expected =
210
217
from_integer (output_expected_value, unsignedbv_typet{output_size});
211
218
// Forcing the type to be pointer_typet otherwise from_integer fails when
@@ -219,11 +226,13 @@ TEST_CASE(
219
226
// Check that replicating to a float_value is same as unsigned_bv.
220
227
const auto result = duplicate_per_byte (
221
228
from_integer (init_expr_value, unsignedbv_typet{init_expr_size}),
222
- float_type ());
229
+ float_type (),
230
+ test.ns );
223
231
const auto expected_unsigned_value =
224
232
expr_try_dynamic_cast<constant_exprt>(duplicate_per_byte (
225
233
from_integer (init_expr_value, unsignedbv_typet{init_expr_size}),
226
- unsignedbv_typet{float_type ().get_width ()}));
234
+ unsignedbv_typet{float_type ().get_width ()},
235
+ test.ns ));
227
236
REQUIRE (expected_unsigned_value);
228
237
const auto expected =
229
238
constant_exprt{expected_unsigned_value->get_value (), float_type ()};
@@ -250,13 +259,13 @@ TEST_CASE(
250
259
SECTION (" Testing with init size " + std::to_string (init_expr_size))
251
260
{
252
261
const auto init_expr = plus_exprt{
253
- from_integer ( 1 , unsignedbv_typet{init_expr_size}) ,
262
+ symbol_exprt{ " a_symbol " , unsignedbv_typet{init_expr_size}} ,
254
263
from_integer (2 , unsignedbv_typet{init_expr_size})};
255
264
SECTION (" filling signedbv of size " + std::to_string (output_size))
256
265
{
257
266
typet output_type = signedbv_typet{output_size};
258
267
259
- const auto result = duplicate_per_byte (init_expr, output_type);
268
+ const auto result = duplicate_per_byte (init_expr, output_type, test. ns );
260
269
261
270
const auto casted_init_expr =
262
271
typecast_exprt::conditional_cast (init_expr, output_type);
@@ -269,7 +278,7 @@ TEST_CASE(
269
278
SECTION (" filling unsignedbv of size " + std::to_string (output_size))
270
279
{
271
280
typet output_type = unsignedbv_typet{output_size};
272
- const auto result = duplicate_per_byte (init_expr, output_type);
281
+ const auto result = duplicate_per_byte (init_expr, output_type, test. ns );
273
282
274
283
const auto casted_init_expr =
275
284
typecast_exprt::conditional_cast (init_expr, output_type);
@@ -284,7 +293,7 @@ TEST_CASE(
284
293
// Check that replicating a pointer_value is same as unsigned_bv modulo a
285
294
// byte_extract outside.
286
295
const pointer_typet output_type{bool_typet{}, output_size};
287
- const auto result = duplicate_per_byte (init_expr, output_type);
296
+ const auto result = duplicate_per_byte (init_expr, output_type, test. ns );
288
297
const auto unsigned_corr_type = unsignedbv_typet{output_size};
289
298
const auto unsigned_init_expr =
290
299
typecast_exprt::conditional_cast (init_expr, unsigned_corr_type);
@@ -306,7 +315,7 @@ TEST_CASE(
306
315
const std::size_t float_replication_count =
307
316
(float_type ().get_width () + config.ansi_c .char_width - 1 ) /
308
317
config.ansi_c .char_width ;
309
- const auto result = duplicate_per_byte (init_expr, float_type ());
318
+ const auto result = duplicate_per_byte (init_expr, float_type (), test. ns );
310
319
const auto unsigned_corr_type =
311
320
unsignedbv_typet{float_type ().get_width ()};
312
321
const auto unsigned_init_expr =
@@ -412,8 +421,8 @@ TEST_CASE(
412
421
const auto result =
413
422
expr_initializer (input_type, test.loc , test.ns , init_value);
414
423
REQUIRE (result.has_value ());
415
- const auto expected =
416
- duplicate_per_byte ( init_value, unsignedbv_typet{input_type_size});
424
+ const auto expected = duplicate_per_byte (
425
+ init_value, unsignedbv_typet{input_type_size}, test. ns );
417
426
REQUIRE (result.value () == expected);
418
427
}
419
428
}
@@ -460,7 +469,7 @@ TEST_CASE(
460
469
expr_initializer (input_type, test.loc , test.ns , init_value);
461
470
REQUIRE (result.has_value ());
462
471
const auto expected = duplicate_per_byte (
463
- init_value, pointer_typet{bool_typet{}, input_type_size});
472
+ init_value, pointer_typet{bool_typet{}, input_type_size}, test. ns );
464
473
REQUIRE (result.value () == expected);
465
474
}
466
475
}
@@ -499,7 +508,8 @@ TEST_CASE("expr_initializer on float type", "[core][util][expr_initializer]")
499
508
const auto result =
500
509
expr_initializer (input_type, test.loc , test.ns , init_value);
501
510
REQUIRE (result.has_value ());
502
- const auto expected = duplicate_per_byte (init_value, float_type ());
511
+ const auto expected =
512
+ duplicate_per_byte (init_value, float_type (), test.ns );
503
513
REQUIRE (result.value () == expected);
504
514
}
505
515
}
@@ -562,13 +572,13 @@ TEST_CASE(
562
572
from_integer (0xAB , signedbv_typet{config.ansi_c .char_width });
563
573
const auto result =
564
574
expr_initializer (enum_type, test.loc , test.ns , init_value);
565
- const auto expected = duplicate_per_byte (init_value, enum_type);
575
+ const auto expected = duplicate_per_byte (init_value, enum_type, test. ns );
566
576
REQUIRE (result.has_value ());
567
577
REQUIRE (result.value () == expected);
568
578
569
579
const auto tag_result =
570
580
expr_initializer (c_enum_tag_type, test.loc , test.ns , init_value);
571
- auto tag_expected = duplicate_per_byte (init_value, enum_type);
581
+ auto tag_expected = duplicate_per_byte (init_value, enum_type, test. ns );
572
582
tag_expected.type () = c_enum_tag_type;
573
583
REQUIRE (tag_result.has_value ());
574
584
REQUIRE (tag_result.value () == tag_expected);
@@ -624,7 +634,7 @@ TEST_CASE(
624
634
expr_initializer (array_type, test.loc , test.ns , init_value);
625
635
REQUIRE (result.has_value ());
626
636
std::vector<exprt> array_values{
627
- elem_count, duplicate_per_byte (init_value, inner_type)};
637
+ elem_count, duplicate_per_byte (init_value, inner_type, test. ns )};
628
638
const auto expected = array_exprt{
629
639
array_values,
630
640
array_typet{
@@ -678,7 +688,7 @@ TEST_CASE(
678
688
expr_initializer (array_type, test.loc , test.ns , init_value);
679
689
REQUIRE (result.has_value ());
680
690
const auto expected = array_of_exprt{
681
- duplicate_per_byte (init_value, inner_type),
691
+ duplicate_per_byte (init_value, inner_type, test. ns ),
682
692
array_typet{
683
693
inner_type, side_effect_expr_nondett{signedbv_typet{8 }, test.loc }}};
684
694
REQUIRE (result.value () == expected);
@@ -750,7 +760,7 @@ TEST_CASE(
750
760
expr_initializer (array_type, test.loc , test.ns , init_value);
751
761
REQUIRE (result.has_value ());
752
762
std::vector<exprt> inner_array_values{
753
- elem_count, duplicate_per_byte (init_value, inner_type)};
763
+ elem_count, duplicate_per_byte (init_value, inner_type, test. ns )};
754
764
const auto inner_expected = array_exprt{
755
765
inner_array_values,
756
766
array_typet{
@@ -847,12 +857,13 @@ TEST_CASE(
847
857
expr_initializer (struct_type, test.loc , test.ns , init_value);
848
858
REQUIRE (result.has_value ());
849
859
const exprt::operandst expected_inner_struct_fields{
850
- duplicate_per_byte (init_value, signedbv_typet{32 }),
851
- duplicate_per_byte (init_value, unsignedbv_typet{16 })};
860
+ duplicate_per_byte (init_value, signedbv_typet{32 }, test. ns ),
861
+ duplicate_per_byte (init_value, unsignedbv_typet{16 }, test. ns )};
852
862
const struct_exprt expected_inner_struct_expr{
853
863
expected_inner_struct_fields, inner_struct_type};
854
864
const exprt::operandst expected_struct_fields{
855
- duplicate_per_byte (init_value, bool_typet{}), expected_inner_struct_expr};
865
+ duplicate_per_byte (init_value, bool_typet{}, test.ns ),
866
+ expected_inner_struct_expr};
856
867
const struct_exprt expected_struct_expr{
857
868
expected_struct_fields, struct_type};
858
869
REQUIRE (result.value () == expected_struct_expr);
@@ -935,7 +946,9 @@ TEST_CASE("expr_initializer on union type", "[core][util][expr_initializer]")
935
946
expr_initializer (union_type, test.loc , test.ns , init_value);
936
947
REQUIRE (result.has_value ());
937
948
const union_exprt expected_union{
938
- " foo" , duplicate_per_byte (init_value, signedbv_typet{256 }), union_type};
949
+ " foo" ,
950
+ duplicate_per_byte (init_value, signedbv_typet{256 }, test.ns ),
951
+ union_type};
939
952
REQUIRE (result.value () == expected_union);
940
953
941
954
const auto union_tag_type =
@@ -945,7 +958,7 @@ TEST_CASE("expr_initializer on union type", "[core][util][expr_initializer]")
945
958
REQUIRE (tag_result.has_value ());
946
959
const union_exprt expected_union_tag{
947
960
" foo" ,
948
- duplicate_per_byte (init_value, signedbv_typet{256 }),
961
+ duplicate_per_byte (init_value, signedbv_typet{256 }, test. ns ),
949
962
union_tag_type};
950
963
REQUIRE (tag_result.value () == expected_union_tag);
951
964
}
@@ -1024,7 +1037,8 @@ TEST_CASE("expr_initializer on string type", "[core][util][expr_initializer]")
1024
1037
const auto result =
1025
1038
expr_initializer (string_type, test.loc , test.ns , init_value);
1026
1039
REQUIRE (result.has_value ());
1027
- const auto expected_string = duplicate_per_byte (init_value, string_type);
1040
+ const auto expected_string =
1041
+ duplicate_per_byte (init_value, string_type, test.ns );
1028
1042
REQUIRE (result.value () == expected_string);
1029
1043
}
1030
1044
}
0 commit comments