@@ -114,26 +114,31 @@ SCENARIO("calculate_max_string_length",
114
114
signedbv_typet (32 ),
115
115
unsignedbv_typet (32 ),
116
116
signedbv_typet (64 ),
117
- unsignedbv_typet (64 )};
117
+ unsignedbv_typet (64 ),
118
+ };
118
119
119
120
for (const typet &type : int_types)
120
121
{
121
- WHEN (std::string (" type = " )+type.pretty ())
122
+ std::string type_str=type.pretty ();
123
+ std::replace (type_str.begin (), type_str.end (), ' \n ' , ' ' );
124
+ WHEN (" type = " +type_str)
122
125
{
123
126
for (const unsigned long radix : radixes)
124
127
{
125
- WHEN (std::string ( " radix = " ) +std::to_string (radix))
128
+ WHEN (" radix = " +std::to_string (radix))
126
129
{
127
130
size_t actual_value=max_printed_string_length (type, radix);
128
- WHEN ( std::string ( " correct value" )+type. pretty () )
131
+ THEN ( " value is correct " )
129
132
{
130
133
size_t expected_value=expected_length (radix, type);
131
- // / Due to floating point rounding errors, we sometime get one more
132
- // / than the actual value, which is perfectly fine for our purposes
133
- REQUIRE (expected_value<=actual_value);
134
- REQUIRE (expected_value+1 >=actual_value);
134
+ // Due to floating point rounding errors, we sometime get one more
135
+ // than the actual value, which is perfectly fine for our purposes
136
+ // Double brackets here prevent Catch trying to decompose a
137
+ // complex expression
138
+ REQUIRE ((
139
+ actual_value==expected_value || actual_value==expected_value+1 ));
135
140
}
136
- WHEN ( std::string ( " value is less than with default radix" ) )
141
+ THEN ( " value is no greater than with default radix" )
137
142
{
138
143
size_t actual_value_for_default=max_printed_string_length (type, 0 );
139
144
REQUIRE (actual_value<=actual_value_for_default);
0 commit comments