Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-zherikov committed Feb 1, 2024
1 parent d82e7fa commit 20ad624
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions source/argparse/internal/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,20 @@ unittest
assert(unrecognizedArgs == ["FAA"]);
assert(c == cmd("FOO"));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["--","FOO"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO"));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["FOO","--","FAA"], unrecognizedArgs));
assert(unrecognizedArgs == ["FAA"]);
assert(c == cmd("FOO"));
}
{
cmd c;
string[] unrecognizedArgs;
Expand All @@ -843,6 +857,13 @@ unittest
assert(unrecognizedArgs == ["FOO"]);
assert(c == cmd("c1"));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["--","c1","FOO"], unrecognizedArgs));
assert(unrecognizedArgs == ["FOO"]);
assert(c == cmd("c1"));
}
{
cmd c;
string[] unrecognizedArgs;
Expand All @@ -857,6 +878,13 @@ unittest
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["FOO","c1","--","FAA","BOO"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
}


Expand Down Expand Up @@ -899,6 +927,27 @@ unittest
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["--","FOO"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO"));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["FOO","--","FAA"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA"))));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["--","FOO","FAA","BOO"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
{
cmd c;
string[] unrecognizedArgs;
Expand All @@ -920,6 +969,20 @@ unittest
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["FOO","c1","--","FAA","BOO"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("FAA","BOO"))));
}
{
cmd c;
string[] unrecognizedArgs;
assert(callParser!(enableStyling(Config.init, false), false)(c, ["--","FOO","c1","FAA"], unrecognizedArgs));
assert(unrecognizedArgs.length == 0);
assert(c == cmd("FOO", typeof(c.c)(c1("c1","FAA"))));
}
}


Expand Down

0 comments on commit 20ad624

Please sign in to comment.