| 13 | using cx = std::complex<double>; |
| 14 | |
| 15 | CLI::Option * |
| 16 | add_option(CLI::App &app, std::string name, cx &variable, std::string description = "", bool defaulted = false) { |
| 17 | CLI::callback_t fun = [&variable](CLI::results_t res) { |
| 18 | double x = 0, y = 0; |
| 19 | bool worked = CLI::detail::lexical_cast(res[0], x) && CLI::detail::lexical_cast(res[1], y); |
| 20 | if(worked) |
| 21 | variable = cx(x, y); |
| 22 | return worked; |
| 23 | }; |
| 24 | |
| 25 | CLI::Option *opt = app.add_option(name, fun, description, defaulted); |
| 26 | opt->type_name("COMPLEX")->type_size(2); |
| 27 | if(defaulted) { |
| 28 | std::stringstream out; |
| 29 | out << variable; |
| 30 | opt->default_str(out.str()); |
| 31 | } |
| 32 | return opt; |
| 33 | } |
| 34 | |
| 35 | TEST_CASE_METHOD(TApp, "AddingComplexParser", "[complex]") { |
| 36 |
no test coverage detected