Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - modules - forperm.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 21061-8feaff2) Lines: 33 33 100.0 %
Date: 2017-09-24 06:24:57 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2017  The PARI group.
       2             : 
       3             : This file is part of the PARI/GP package.
       4             : 
       5             : PARI/GP is free software; you can redistribute it and/or modify it under the
       6             : terms of the GNU General Public License as published by the Free Software
       7             : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       8             : ANY WARRANTY WHATSOEVER.
       9             : 
      10             : Check the License for details. You should have received a copy of it, along
      11             : with the package; see the file 'COPYING'. If not, write to the Free Software
      12             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      13             : 
      14             : /* for loop over permutations in lexicographic order
      15             :  * This implements the algorithm L in D. Knuth "The Art Of Computer Programming"
      16             :  * Fascicle 2b */
      17             : 
      18             : #include "pari.h"
      19             : #include "paripriv.h"
      20             : 
      21             : void
      22         112 : forperm_init(forperm_t *T, GEN k)
      23             : {
      24         112 :   switch (typ(k))
      25             :   {
      26             :     case t_INT:
      27          63 :       if (signe(k) < 0) pari_err_DOMAIN("forperm", "a", "<", gen_0, k);
      28          56 :       T->v = identity_perm(itou(k)); break;
      29             :     case t_VEC:
      30          28 :       T->v = vec_to_vecsmall(k); break;
      31             :     case t_VECSMALL:
      32          14 :       T->v = vecsmall_copy(k); break;
      33             :     default:
      34           7 :       pari_err_TYPE("forperm", k);
      35             :       return; /* LCOV_EXCL_LINE */
      36             :   }
      37          98 :   T->first = 1;
      38          98 :   T->k = lg(T->v) - 1;
      39             : }
      40             : 
      41             : GEN
      42        2261 : forperm_next(forperm_t *T)
      43             : {
      44        2261 :   long k = T->k, m1, m2, *p, *q;
      45        2261 :   GEN v = T->v;
      46             : 
      47        2261 :   if (T->first) { T->first = 0; return v; }
      48        2163 :   m1 = k-1; while (m1 > 0 && v[m1] >= v[m1+1]) m1--;
      49        2163 :   if (m1 <= 0) return NULL;
      50             : 
      51        2065 :   m2 = k; while (v[m1] >= v[m2]) m2--;
      52        2065 :   lswap(v[m1], v[m2]);
      53        2065 :   p = v + m1 + 1;
      54        2065 :   q = v + k;
      55        2065 :   while (p < q) { lswap(*p, *q); p++; q--; }
      56        2065 :   return v;
      57             : }
      58             : 
      59             : void
      60         112 : forperm(void *E, long call(void *, GEN), GEN k)
      61             : {
      62         112 :   pari_sp av = avma;
      63             :   forperm_t T;
      64             :   GEN v;
      65             : 
      66         112 :   forperm_init(&T, k);
      67          98 :   while ((v = forperm_next(&T)))
      68        2163 :     if (call(E, v)) break;
      69          98 :   avma = av;
      70          98 : }
      71             : 
      72             : void
      73         112 : forperm0(GEN k, GEN code)
      74             : {
      75         112 :   push_lex(gen_0, code);
      76         112 :   forperm((void *)code, &gp_evalvoid, k);
      77          98 :   pop_lex(1);
      78          98 : }
      79             : 

Generated by: LCOV version 1.11