Re: [PATCH v9 1/3] parse-options.c: make OPTION__COUNTUP consider negative values
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 28, 2016, 19:03 UTC
- Message-ID
- <CAPig+cR63D2L8dXJe9Gx-zFXr4-gNaFC6GdfWNPnt4d=Ds8tWg@mail.gmail.com>
- In-Reply-To
- <CAFZEwPP5Hq0fM3Fhg+JV-aY6bWozjL6m_bNpb=JhjkUjDJu2sw@mail.gmail.com>
On Mon, Mar 28, 2016 at 2:42 PM, Pranit Bauva <pranit.bauva@gmail.com> wrote:
Show 23 quoted lines
>> A couple of new tests to t0040-parse-options.sh would be great to >> ensure that starting from a negative value works as advertised, i.e. >> at least that '--option' jumps to 1 and '--no-option' resets to 0. > > I think adding tests to t0040-parse-options.sh cannot reflect the > behavior introduced by this patch. > This is because setting the initial value of the variable (which is > going to be modified by the argument) is set in test-parse-options.c . > A possible solution will be to modify the test-parse-options.c and > initialize the required variable (verbose or quiet) to "unspecified" > value. But then this will leave one part of the untested ie. when the > initial value of the variable is 0. I could do one thing to test these > both behaviors which is to set verbose initially to -1 and leave quiet > = 0. Since verbose and quiet are both consumers of OPT_COUNTUP, this > can test both the behaviors. > > I tried searching for alternatives but could not find any. Is there > something else which you had thought before that would test this > behavior? > > If not, then we are left with 2 options, either modify > test-parse-options.c or just hand test it whenever there seems to be a > problematic case.
Modifying test-parse-options.c, if needed, was implied by SZEDER's suggestion to add tests for this new behavior. test-parse-options.c exists strictly for testing option parsing, so don't feel constrained about modifying or extending it in order to test the new count-up behavior if the existing implementation doesn't directly support what you want it to do.