So, the problem is that I was trying to test a wrapper of your library I have made for my application.
Only the first test case was always passing, but every other would fail.
After a long time of searching I found the culprit. In the file Arg.h there are the following lines:
/** * Indicates whether the rest of the arguments should be ignored. */
staticbool&ignoreRestRef(){staticboolign=false;returnign;}/** * The delimiter that separates an argument flag/name from the * value. */
staticchar&delimiterRef(){staticchardelim=' ';returndelim;}
Some of the tests I wrote were adding "--" (the argument after which every other is ignored) to the arguments sequence.
I must admit, it was caused by my laziness. I have been using the same utility fuction for both ValueArgs and SwitchArgs.
For convenience, the default value was that unfortunate double-dash.
I can fix my tests easily, but I can see many use cases where this behavior will cause problems, for instance:
multiple processes parsing their arguments using a deamon parser
parsing arguments from multiple sources
parsing arguments at different times during program execution
I wrote an (almost) minimal code example that highlights the issue:
So, the problem is that I was trying to test a wrapper of your library I have made for my application.
Only the first test case was always passing, but every other would fail.
After a long time of searching I found the culprit. In the file Arg.h there are the following lines:
Some of the tests I wrote were adding "--" (the argument after which every other is ignored) to the arguments sequence.
I must admit, it was caused by my laziness. I have been using the same utility fuction for both ValueArgs and SwitchArgs.
For convenience, the default value was that unfortunate double-dash.
I can fix my tests easily, but I can see many use cases where this behavior will cause problems, for instance:
I wrote an (almost) minimal code example that highlights the issue:
It produces the following output:
Where it should be:
Yea, that's annoying. I've created https://sourceforge.net/p/tclap/bugs/25/ to track this issue.
This specfic problem is fixed in [2a4ae2] (test case now pass).
Related
Commit: [2a4ae2]