predicates icon indicating copy to clipboard operation
predicates copied to clipboard

Invalid incircle unit test

Open kireevtf opened this issue 6 years ago • 2 comments

The incircle unit test is invalid. There is a roundoff in r2 calculation, so r2 is always equals to n*n despite the perturbation of q.

const double y[] = {q[0] - x[0], q[1] - x[1]};
const double r2 = y[0]*y[0] + y[1]*y[1];

if (r2 < n*n) assert(p > 0);
else if (r2 > n*n) assert(p < 0);

Hence the assertion statements are never executed. You can write

if (r2 < n*n) assert(0);
else if (r2 > n*n) assert(0);

to check it out.

kireevtf avatar Feb 07 '19 13:02 kireevtf

Well that's embarrassing, good catch! My first thought is to use the GNU multi-precision library. If you want to fix this I'd gladly accept the PR, or I can do that myself.

A code coverage analyzer would have made it obvious that neither of those branches was taken.

danshapero avatar Feb 07 '19 21:02 danshapero

Sorry. I think there's no strong reason to fix this since the easy case test works well.

kireevtf avatar Feb 08 '19 06:02 kireevtf