Unit Testing in Action

Walter Bright newshound2 at digitalmars.com
Tue Oct 24 20:51:36 UTC 2017


On 10/23/2017 4:44 AM, Martin Nowak wrote:
> On Saturday, 21 October 2017 at 22:50:51 UTC, Walter Bright wrote:
>> Coverage would give:
>>
>> 1|    x = 2;
>> 2|    if (x == 1 || x == 2)
>>
>> I.e. the second line gets an execution count of 2. By contrast,
>>
>> 1|    x = 1;
>> 1|    if (x == 1 || x == 2)
> 
> Interesting point, but would likely fail for more complex stuff.
> 
> 1| stmt;
> 2| if (api1 == 1 && api2 == 2 ||
>         api2 == 2 && api3 == 3)

There would be a separate coverage count for line 3 which would be the sum of 
counts for (api2 == 2) and (api3 == 3).

Generally, if this is inadequate, just split the expression into more lines.

The same thing for for loop statements and ?:


> Anyhow, I think the current state is good enough and there are gdc/ldc for 
> further coverage features.




More information about the Digitalmars-d-announce mailing list