flint icon indicating copy to clipboard operation
flint copied to clipboard

Template boilerplate tests

Open albinahlback opened this issue 1 year ago • 2 comments

We should probably make templates for tests. Not sure how to go about this nicely.

As Max discovered in #2102, we do not test certain cases for some functions (in this example it was the zero polynomial minus a zero integer that is never tested, which did crash).

While all functions are tested with "hardcoded" test code (where some actually need it), for sort of more boilerplaty functions it becomes harder to go get a good overview of the code when everything is "hardcoded". It could also be more prone to errors, such as this case.

Hence, I would strongly suggest we look into templating boilerplate tests.

albinahlback avatar Oct 27 '24 21:10 albinahlback

Note that this bug would probably have been caught by the generic ring tests if the _fmpz variants were wrapped in https://github.com/flintlib/flint/blob/main/src/gr/fmpz_poly.c

Edit: it isn't caught, because of the way the test code is written. The problematic input isn't specifically the zero polynomial, but a polynomial with zero alloc, and this doesn't get caught because the test code reuses variables and never tests sub_fmpz with a freshly allocated variable. Note that we need to do both cases: we've had plenty of bugs for the case where the output variables is not freshly initialized, which the test code didn't cover.

fredrik-johansson avatar Oct 28 '24 08:10 fredrik-johansson

I think it sounds very reasonable to do this through GR!

albinahlback avatar Oct 28 '24 11:10 albinahlback