17 std::optional<int> int2;
19 std::optional<double> dbl2;
21 std::optional<std::string> s2;
22 std::vector<int> ints;
26 auto table = std::to_array<const ArgsInfo>({
38 std::span<const TclObject, 0> in;
46 SECTION(
"only normal args") {
50 CHECK(out.size() == 3);
51 CHECK(out[0] ==
"arg1");
57 SECTION(
"(regular) integer option") {
65 SECTION(
"(optional) integer option") {
74 SECTION(
"(regular) double option") {
81 SECTION(
"(regular) string option") {
86 CHECK(s1 ==
"foobar");
88 SECTION(
"flag value") {
95 SECTION(
"multiple options and args") {
102 CHECK(out.size() == 3);
103 CHECK(out[0] ==
"bla");
104 CHECK(out[1] ==
"qwerty");
105 CHECK(out[2] ==
"zyxwv");
114 SECTION(
"set same option twice") {
118 CHECK(out.size() == 1);
121 SECTION(
"vector<T> accepts repeated options") {
126 CHECK(ints.size() == 2);
127 CHECK(ints[0] == 11);
128 CHECK(ints[1] == 22);
130 SECTION(
"no options after --") {
134 CHECK(out.size() == 2);
135 CHECK(out[0] ==
"-int1");
136 CHECK(out[1] ==
"234");
139 SECTION(
"missing value for option") {
143 SECTION(
"non-integer value for integer-option") {
147 SECTION(
"non-double value for double-option") {
151 SECTION(
"unknown option") {
This file implemented 3 utility functions:
ArgsInfo valueArg(std::string_view name, T &value)
std::vector< TclObject > parseTclArgs(Interpreter &interp, std::span< const TclObject > inArgs, std::span< const ArgsInfo > table)
ArgsInfo flagArg(std::string_view name, bool &flag)
TEST_CASE("TclArgParser")