@@ -90,57 +90,19 @@ void function_call_harness_generatort::handle_option(
90
90
const std::string &option,
91
91
const std::list<std::string> &values)
92
92
{
93
- if (option == FUNCTION_HARNESS_GENERATOR_FUNCTION_OPT)
94
- {
95
- p_impl->function = require_exactly_one_value (option, values);
96
- }
97
- else if (option == FUNCTION_HARNESS_GENERATOR_NONDET_GLOBALS_OPT)
98
- {
99
- p_impl->nondet_globals = true ;
100
- }
101
- else if (option == FUNCTION_HARNESS_GENERATOR_MIN_NULL_TREE_DEPTH_OPT)
102
- {
103
- auto const value = require_exactly_one_value (option, values);
104
- auto const min_null_tree_depth = string2optional<std::size_t >(value, 10 );
105
- if (min_null_tree_depth.has_value ())
106
- {
107
- p_impl->recursive_initialization_config .min_null_tree_depth =
108
- min_null_tree_depth.value ();
109
- }
110
- else
111
- {
112
- throw invalid_command_line_argument_exceptiont{
113
- " failed to convert `" + value + " ' to integer" ,
114
- " --" FUNCTION_HARNESS_GENERATOR_MIN_NULL_TREE_DEPTH_OPT};
115
- }
116
- }
117
- else if (option == FUNCTION_HARNESS_GENERATOR_MAX_NONDET_TREE_DEPTH_OPT)
93
+ auto &require_exactly_one_value =
94
+ harness_options_parsert::require_exactly_one_value;
95
+
96
+ if (p_impl->recursive_initialization_config .handle_option (option, values))
118
97
{
119
- auto const value = require_exactly_one_value (option, values);
120
- auto const max_nondet_tree_depth = string2optional<std::size_t >(value, 10 );
121
- if (max_nondet_tree_depth.has_value ())
122
- {
123
- p_impl->recursive_initialization_config .max_nondet_tree_depth =
124
- max_nondet_tree_depth.value ();
125
- }
126
- else
127
- {
128
- throw invalid_command_line_argument_exceptiont{
129
- " failed to convert `" + value + " ' to integer" ,
130
- " --" FUNCTION_HARNESS_GENERATOR_MAX_NONDET_TREE_DEPTH_OPT};
131
- }
132
98
}
133
- else if (option == FUNCTION_HARNESS_GENERATOR_MAX_ARRAY_SIZE_OPT )
99
+ else if (option == FUNCTION_HARNESS_GENERATOR_FUNCTION_OPT )
134
100
{
135
- p_impl->recursive_initialization_config .max_dynamic_array_size =
136
- require_one_size_value (
137
- FUNCTION_HARNESS_GENERATOR_MAX_ARRAY_SIZE_OPT, values);
101
+ p_impl->function = require_exactly_one_value (option, values);
138
102
}
139
- else if (option == FUNCTION_HARNESS_GENERATOR_MIN_ARRAY_SIZE_OPT )
103
+ else if (option == COMMON_HARNESS_GENERATOR_NONDET_GLOBALS_OPT )
140
104
{
141
- p_impl->recursive_initialization_config .min_dynamic_array_size =
142
- require_one_size_value (
143
- FUNCTION_HARNESS_GENERATOR_MIN_ARRAY_SIZE_OPT, values);
105
+ p_impl->nondet_globals = true ;
144
106
}
145
107
else if (option == FUNCTION_HARNESS_GENERATOR_TREAT_POINTER_AS_ARRAY_OPT)
146
108
{
@@ -285,25 +247,8 @@ void function_call_harness_generatort::validate_options(
285
247
{
286
248
throw invalid_command_line_argument_exceptiont{
287
249
" min dynamic array size cannot be greater than max dynamic array size" ,
288
- " --" FUNCTION_HARNESS_GENERATOR_MIN_ARRAY_SIZE_OPT
289
- " --" FUNCTION_HARNESS_GENERATOR_MAX_ARRAY_SIZE_OPT};
290
- }
291
- }
292
-
293
- std::size_t function_call_harness_generatort::require_one_size_value (
294
- const std::string &option,
295
- const std::list<std::string> &values)
296
- {
297
- auto const string_value = require_exactly_one_value (option, values);
298
- auto value = string2optional<std::size_t >(string_value, 10 );
299
- if (value.has_value ())
300
- {
301
- return value.value ();
302
- }
303
- else
304
- {
305
- throw invalid_command_line_argument_exceptiont{
306
- " failed to parse `" + string_value + " ' as integer" , " --" + option};
250
+ " --" COMMON_HARNESS_GENERATOR_MIN_ARRAY_SIZE_OPT
251
+ " --" COMMON_HARNESS_GENERATOR_MAX_ARRAY_SIZE_OPT};
307
252
}
308
253
}
309
254
0 commit comments