Skip to content

Commit 1fe074f

Browse files
Add helper to get exactly one size value
Small helper to convert a program argument to size_t and throw an exception if it doesn't work. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
1 parent db99c4b commit 1fe074f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/goto-harness/function_call_harness_generator.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ void function_call_harness_generatort::validate_options()
185185
"--" FUNCTION_HARNESS_GENERATOR_FUNCTION_OPT};
186186
}
187187

188+
std::size_t function_call_harness_generatort::require_one_size_value(
189+
const std::string &option,
190+
const std::list<std::string> &values)
191+
{
192+
static auto const string_value = require_exactly_one_value(option, values);
193+
// TODO replace this with string2optional
194+
return narrow<std::size_t>(std::stoull(string_value));
195+
}
196+
188197
const symbolt &
189198
function_call_harness_generatort::implt::lookup_function_to_call()
190199
{

src/goto-harness/function_call_harness_generator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class function_call_harness_generatort : public goto_harness_generatort
3636
void validate_options() override;
3737

3838
private:
39+
std::size_t require_one_size_value(
40+
const std::string &option,
41+
const std::list<std::string> &values);
3942
struct implt;
4043
std::unique_ptr<implt> p_impl;
4144
};

0 commit comments

Comments
 (0)