On Wed, Jun 19, 2024 at 5:37 PM Sergei Trofimovich <sly...@gmail.com> wrote: > Glancing at tests/ all the tests exercise user-facing `make` API. What > would be the best way to validate probabilities?
For this type of code like shuffle, i like testing the function itself, directly. Just calling the function in a test program and giving it hardcoded input and checking the output. This allows testing edge cases easily. One option is to rename a.c to shuffle.t.c and replace printf statements in shuffle.t.c with test checks. shuffle.t.c will need to be added to Makefile.am to have `make check' build the binary from shuffle.t.c and execute the binary and react to its exit code. You can see an example of such a test, called token.t.c, here https://file.savannah.gnu.org/file/sv65588_part2.diff?file_id=55942. See changes in Makefile.am. To see this in action, you can apply the patches from https://savannah.gnu.org/bugs/?65588 and run `make check' and see how make builds token.t.tsk (from token.t.c) and runs it. i hope, Paul approves adding tests of this nature. regards, Dmitry