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 - graph - plottty.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 21072-998352a) Lines: 86 87 98.9 %
Date: 2017-09-26 06:25:23 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright (C) 2016  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             : /********************************************************************/
      18             : /**                                                                **/
      19             : /**                         LOW-RES PLOT                           **/
      20             : /**                                                                **/
      21             : /********************************************************************/
      22             : #define ISCR 64
      23             : #define JSCR 22
      24             : 
      25             : INLINE long
      26        1472 : DTOL(double t) { return (long)(t + 0.5); }
      27             : 
      28             : static char
      29        1472 : PICT(long j) {
      30        1472 :   switch(j%3) {
      31         743 :     case 0:  return '_';
      32         242 :     case 1:  return 'x';
      33         487 :     default: return '"';
      34             :   }
      35             : }
      36             : static char
      37          23 : PICTZERO(long j) {
      38          23 :   switch(j%3) {
      39           8 :     case 0:  return ',';
      40           4 :     case 1:  return '-';
      41          11 :     default: return '`';
      42             :   }
      43             : }
      44             : 
      45             : static char *
      46          46 : dsprintf9(double d, char *buf)
      47             : {
      48          46 :   int i = 10;
      49             : 
      50         112 :   while (--i >= 0) {
      51          66 :     sprintf(buf, "%9.*g", i, d);
      52          66 :     if (strlen(buf) <= 9) return buf;
      53             :   }
      54           0 :   return buf; /* Should not happen? */
      55             : }
      56             : 
      57             : typedef unsigned char screen[ISCR+1][JSCR+1];
      58             : 
      59             : static void
      60        1449 : fill_gap(screen scr, long i, int jnew, int jpre)
      61             : {
      62             :   int mid, i_up, i_lo, up, lo;
      63             : 
      64        1449 :   if (jpre < jnew - 2) {
      65           4 :     up = jnew - 1; i_up = i;
      66           4 :     lo = jpre + 1; i_lo = i - 1;
      67        1445 :   } else if (jnew < jpre - 2) {
      68           4 :     up = jpre - 1; i_up = i - 1;
      69           4 :     lo = jnew + 1; i_lo = i;
      70        2890 :   } else return; /* if gap < 2, leave it as it is. */
      71             : 
      72           8 :   mid = (jpre+jnew)/2;
      73           8 :   if (mid>JSCR) mid=JSCR; else if (mid<0) mid=0;
      74           8 :   if (lo<0) lo=0;
      75           8 :   if (lo<=JSCR) while (lo <= mid) scr[i_lo][lo++] = ':';
      76           8 :   if (up>JSCR) up=JSCR;
      77           8 :   if (up>=0) while (up > mid) scr[i_up][up--] = ':';
      78             : }
      79             : 
      80             : static double
      81          46 : todbl(GEN x) { return rtodbl(gtofp(x, LOWDEFAULTPREC)); }
      82             : 
      83             : /* code is either a t_CLOSURE (from GP: ploth, etc.) or a t_POL/t_VEC of
      84             :  * two t_POLs from rectsplines */
      85             : static GEN
      86        1472 : READ_EXPR(GEN code, GEN x) {
      87        1472 :   if (typ(code)!=t_CLOSURE) return gsubst(code,0,x);
      88        1472 :   set_lex(-1, x); return closure_evalgen(code);
      89             : }
      90             : 
      91             : void
      92          23 : pariplot(GEN a, GEN b, GEN code, GEN ysmlu,GEN ybigu, long prec)
      93             : {
      94          23 :   const char BLANK = ' ', YY = '|', XX_UPPER = '\'', XX_LOWER = '.';
      95             :   long jz, j, i, sig;
      96          23 :   pari_sp av = avma;
      97          23 :   int jnew, jpre = 0; /* for lint */
      98             :   GEN x, dx;
      99             :   double diff, dyj, ysml, ybig, y[ISCR+1];
     100             :   screen scr;
     101             :   char buf[80], z;
     102             : 
     103          46 :   sig=gcmp(b,a); if (!sig) return;
     104          23 :   if (sig<0) { x=a; a=b; b=x; }
     105          23 :   x = gtofp(a, prec); push_lex(x, code);
     106          23 :   dx = divru(gtofp(gsub(b,a),prec), ISCR-1);
     107          23 :   for (j=1; j<=JSCR; j++) scr[1][j]=scr[ISCR][j]=YY;
     108        1449 :   for (i=2; i<ISCR; i++)
     109             :   {
     110        1426 :     scr[i][1]   = XX_LOWER;
     111        1426 :     scr[i][JSCR]= XX_UPPER;
     112        1426 :     for (j=2; j<JSCR; j++) scr[i][j] = BLANK;
     113             :   }
     114          23 :   ysml = ybig = 0.; /* -Wall */
     115        1495 :   for (i=1; i<=ISCR; i++)
     116             :   {
     117        1472 :     pari_sp av2 = avma;
     118        1472 :     y[i] = gtodouble( READ_EXPR(code,x) );
     119        1472 :     avma = av2;
     120        1472 :     if (i == 1)
     121          23 :       ysml = ybig = y[1];
     122             :     else
     123             :     {
     124        1449 :       if (y[i] < ysml) ysml = y[i];
     125        1449 :       if (y[i] > ybig) ybig = y[i];
     126             :     }
     127        1472 :     x = addrr(x,dx);
     128             :   }
     129          23 :   avma = av;
     130          23 :   if (ysmlu) ysml = gtodouble(ysmlu);
     131          23 :   if (ybigu) ybig = gtodouble(ybigu);
     132          23 :   diff = ybig - ysml;
     133          23 :   if (!diff) { ybig += 1; diff= 1.; }
     134          23 :   dyj = ((JSCR-1)*3+2) / diff;
     135             :   /* work around bug in gcc-4.8 (32bit): plot(x=-5,5,sin(x)))) */
     136          23 :   jz = 3 - (long)(ysml*dyj + 0.5); /* 3 - DTOL(ysml*dyj) */
     137          23 :   z = PICTZERO(jz); jz /= 3;
     138        1495 :   for (i=1; i<=ISCR; i++)
     139             :   {
     140        1472 :     if (0<=jz && jz<=JSCR) scr[i][jz]=z;
     141        1472 :     j = 3 + DTOL((y[i]-ysml)*dyj);
     142        1472 :     jnew = j/3;
     143        1472 :     if (i > 1) fill_gap(scr, i, jnew, jpre);
     144        1472 :     if (0<=jnew && jnew<=JSCR) scr[i][jnew] = PICT(j);
     145        1472 :     jpre = jnew;
     146             :   }
     147          23 :   pari_putc('\n');
     148          23 :   pari_printf("%s ", dsprintf9(ybig, buf));
     149          23 :   for (i=1; i<=ISCR; i++) pari_putc(scr[i][JSCR]);
     150          23 :   pari_putc('\n');
     151         483 :   for (j=(JSCR-1); j>=2; j--)
     152             :   {
     153         460 :     pari_puts("          ");
     154         460 :     for (i=1; i<=ISCR; i++) pari_putc(scr[i][j]);
     155         460 :     pari_putc('\n');
     156             :   }
     157          23 :   pari_printf("%s ", dsprintf9(ysml, buf));
     158          23 :   for (i=1; i<=ISCR; i++)  pari_putc(scr[i][1]);
     159          23 :   pari_putc('\n');
     160             :   {
     161             :     char line[10 + 32 + 32 + ISCR - 9];
     162          23 :     sprintf(line, "%10s%-9.7g%*.7g\n"," ",todbl(a),ISCR-9,todbl(b));
     163          23 :     pari_printf(line);
     164             :   }
     165          23 :   pop_lex(1);
     166             : }
     167             : 

Generated by: LCOV version 1.11