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 - forsubset.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 21348-d75f58f) Lines: 52 52 100.0 %
Date: 2017-11-20 06:21:05 Functions: 7 7 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             : #include "pari.h"
      15             : #include "paripriv.h"
      16             : 
      17             : void
      18         168 : forksubset_init(forsubset_t *T, long n, long k)
      19             : {
      20         168 :   T->all = 0;
      21         168 :   T->first = 1;
      22         168 :   T->n = n;
      23         168 :   T->k = k;
      24         168 :   T->v = identity_perm(k);
      25         168 : }
      26             : 
      27             : void
      28          63 : forallsubset_init(forsubset_t *T, long n)
      29             : {
      30          63 :   T->all = 1;
      31          63 :   T->first = 1;
      32          63 :   T->n = n;
      33          63 :   T->k = 0;
      34          63 :   T->v = vecsmalltrunc_init(n + 1);
      35          63 : }
      36             : 
      37             : static GEN
      38        1239 : forksubset_next(forsubset_t *T)
      39             : {
      40        1239 :   GEN v = T->v;
      41        1239 :   long i, n = T->n, k = T->k;
      42             : 
      43        1239 :   if (T->first) { T->first = 0; return (k >= 0 && k <= n) ? v: NULL; }
      44        1008 :   if (k <= 0 || k >= n) return NULL;
      45             : 
      46         826 :   if (v[k] < n) { v[k]++; return v; }
      47         413 :   for (i = k - 1; i >= 1 && v[i+1] == v[i] + 1; i--);
      48         413 :   if (i == 0) return NULL;
      49             : 
      50         252 :   v[i]++;
      51         252 :   for (; i < k; i++) v[i+1] = v[i] + 1;
      52         252 :   return v;
      53             : }
      54             : static GEN
      55         623 : forallsubset_next(forsubset_t *T)
      56             : {
      57             :   long i;
      58             : 
      59         623 :   if (forksubset_next(T)) return T->v;
      60         196 :   else if (T->k < T->n)
      61             :   {
      62         133 :     (T->k)++;
      63         133 :     setlg(T->v, T->k+1);
      64         133 :     for (i = 1; i <= T->k; i++) (T->v)[i] = i;
      65         133 :     return T->v;
      66             :   }
      67          63 :   return NULL;
      68             : }
      69             : GEN
      70        1239 : forsubset_next(forsubset_t *T)
      71        1239 : { return T->all? forallsubset_next(T): forksubset_next(T); }
      72             : void
      73         238 : forsubset_init(forsubset_t *T, GEN nk)
      74             : {
      75         238 :   switch(typ(nk))
      76             :   {
      77          63 :     case t_INT: forallsubset_init(T, itos(nk)); return;
      78             :     case t_VEC:
      79         168 :       if (lg(nk) == 3)
      80             :       {
      81         168 :         GEN n = gel(nk,1), k = gel(nk,2);
      82         168 :         if (typ(n) == t_INT && typ(k) == t_INT)
      83         168 :           return forksubset_init(T, itos(n),itos(k));
      84             :       }
      85             :     default:
      86           7 :       pari_err_TYPE("forsubset", nk);
      87             :   }
      88             : }
      89             : void
      90         238 : forsubset0(GEN nk, GEN code)
      91             : {
      92         238 :   pari_sp av = avma;
      93             :   forsubset_t T;
      94         238 :   void *E = (void*)code;
      95             :   GEN v;
      96         238 :   push_lex(gen_0, code);
      97         238 :   forsubset_init(&T, nk);
      98         231 :   while ((v = forsubset_next(&T)))
      99        1008 :     if (gp_evalvoid(E, v)) break;
     100         231 :   pop_lex(1); avma = av;
     101         231 : }

Generated by: LCOV version 1.11