Skip to content

Commit 11c8aba

Browse files
Fixed calculate_max_string_length unit test to work in CLion
1 parent 22a68fe commit 11c8aba

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

unit/solvers/refinement/string_constraint_generator_valueof/calculate_max_string_length.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,31 @@ SCENARIO("calculate_max_string_length",
114114
signedbv_typet(32),
115115
unsignedbv_typet(32),
116116
signedbv_typet(64),
117-
unsignedbv_typet(64)};
117+
unsignedbv_typet(64),
118+
};
118119

119120
for(const typet &type : int_types)
120121
{
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)
122125
{
123126
for(const unsigned long radix : radixes)
124127
{
125-
WHEN(std::string("radix = ")+std::to_string(radix))
128+
WHEN("radix = "+std::to_string(radix))
126129
{
127130
size_t actual_value=max_printed_string_length(type, radix);
128-
WHEN(std::string("correct value")+type.pretty())
131+
THEN("value is correct")
129132
{
130133
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));
135140
}
136-
WHEN(std::string("value is less than with default radix"))
141+
THEN("value is no greater than with default radix")
137142
{
138143
size_t actual_value_for_default=max_printed_string_length(type, 0);
139144
REQUIRE(actual_value<=actual_value_for_default);

0 commit comments

Comments
 (0)