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-bordeaux1.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 - kernel/none - cmp.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 16804-345a01c) Lines: 59 62 95.2 %
Date: 2014-09-20 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 84 108 77.8 %

           Branch data     Line data    Source code
       1                 :            : #line 2 "../src/kernel/none/cmp.c"
       2                 :            : /* Copyright (C) 2002-2003  The PARI group.
       3                 :            : 
       4                 :            : This file is part of the PARI/GP package.
       5                 :            : 
       6                 :            : PARI/GP is free software; you can redistribute it and/or modify it under the
       7                 :            : terms of the GNU General Public License as published by the Free Software
       8                 :            : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       9                 :            : ANY WARRANTY WHATSOEVER.
      10                 :            : 
      11                 :            : Check the License for details. You should have received a copy of it, along
      12                 :            : with the package; see the file 'COPYING'. If not, write to the Free Software
      13                 :            : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14                 :            : 
      15                 :            : 
      16                 :            : /********************************************************************/
      17                 :            : /**                                                                **/
      18                 :            : /**                      Comparison routines                       **/
      19                 :            : /**                                                                **/
      20                 :            : /********************************************************************/
      21                 :            : 
      22                 :            : /*They depend on cmpiispec and equaliispec in mp.c*/
      23                 :            : 
      24                 :            : int
      25                 :   41392580 : equalii(GEN x, GEN y)
      26                 :            : {
      27         [ +  + ]:   41392580 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      28                 :   41392580 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      29                 :            : }
      30                 :            : 
      31                 :            : int
      32                 :  176801684 : cmpii(GEN x, GEN y)
      33                 :            : {
      34                 :  176801684 :   const long sx = signe(x), sy = signe(y);
      35         [ +  + ]:  176801684 :   if (sx<sy) return -1;
      36         [ +  + ]:  175586603 :   if (sx>sy) return 1;
      37         [ +  + ]:  167751267 :   if (!sx) return 0;
      38         [ +  + ]:  167386217 :   if (sx>0)
      39                 :  163273885 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      40                 :            :   else
      41                 :  176801684 :     return -cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      42                 :            : }
      43                 :            : 
      44                 :            : int
      45                 :         28 : equalrr(GEN x, GEN y)
      46                 :            : {
      47                 :            :   long lx, ly, i;
      48                 :            : 
      49         [ +  + ]:         28 :   if (!signe(x)) return signe(y) == 0; /* all zeroes are equal */
      50         [ +  + ]:         21 :   if (x[1] != y[1]) return 0; /* includes signe(y) = 0 */
      51                 :            : 
      52                 :         14 :   lx = lg(x);
      53                 :         14 :   ly = lg(y);
      54         [ -  + ]:         14 :   if (lx < ly)
      55                 :            :   {
      56 [ #  # ][ #  # ]:          0 :     i=2; while (i<lx && x[i]==y[i]) i++;
      57         [ #  # ]:          0 :     if (i<lx) return 0;
      58 [ #  # ][ #  # ]:          0 :     for (; i < ly; i++) if (y[i]) return 0;
      59                 :            :   }
      60                 :            :   else
      61                 :            :   {
      62 [ +  + ][ +  - ]:         77 :     i=2; while (i<ly && x[i]==y[i]) i++;
      63         [ -  + ]:         14 :     if (i<ly) return 0;
      64 [ #  # ][ -  + ]:         14 :     for (; i < lx; i++) if (x[i]) return 0;
      65                 :            :   }
      66                 :         28 :   return 1;
      67                 :            : }
      68                 :            : 
      69                 :            : int
      70                 :  106952482 : cmprr(GEN x, GEN y)
      71                 :            : {
      72                 :  106952482 :   const long sx = signe(x), sy = signe(y);
      73                 :            :   long ex,ey,lx,ly,lz,i;
      74                 :            : 
      75         [ +  + ]:  106952482 :   if (sx<sy) return -1;
      76         [ +  + ]:  106789670 :   if (sx>sy) return 1;
      77         [ +  + ]:  106703569 :   if (!sx) return 0;
      78                 :            : 
      79                 :  106667820 :   ex=expo(x); ey=expo(y);
      80         [ +  + ]:  106667820 :   if (ex>ey) return sx;
      81         [ +  + ]:   71286949 :   if (ex<ey) return -sx;
      82                 :            : 
      83                 :   38692262 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      84 [ +  + ][ +  + ]:   97602164 :   i=2; while (i<lz && x[i]==y[i]) i++;
      85 [ +  + ][ +  + ]:   38692262 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
      86         [ +  + ]:   16131214 :   if (lx>=ly)
      87                 :            :   {
      88 [ +  + ][ -  + ]:   16131172 :     while (i<lx && !x[i]) i++;
      89         [ +  + ]:   16131172 :     return (i==lx) ? 0 : sx;
      90                 :            :   }
      91 [ +  + ][ +  - ]:        202 :   while (i<ly && !y[i]) i++;
      92         [ -  + ]:  106952482 :   return (i==ly) ? 0 : -sx;
      93                 :            : }
      94                 :            : 
      95                 :            : /* x and y are integers. Return 1 if |x| == |y|, 0 otherwise */
      96                 :            : int
      97                 :    2681162 : absi_equal(GEN x, GEN y)
      98                 :            : {
      99         [ +  + ]:    2681162 :   if (!signe(x)) return !signe(y);
     100         [ +  + ]:    2676451 :   if (!signe(y)) return 0;
     101                 :    2681162 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     102                 :            : }
     103                 :            : 
     104                 :            : /* x and y are integers. Return sign(|x| - |y|) */
     105                 :            : int
     106                 :  426175920 : absi_cmp(GEN x, GEN y)
     107                 :            : {
     108 [ +  + ][ +  + ]:  426175920 :   if (!signe(x)) return signe(y)? -1: 0;
     109         [ +  + ]:  411927891 :   if (!signe(y)) return 1;
     110                 :  426175920 :   return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     111                 :            : }
     112                 :            : 
     113                 :            : /* x and y are reals. Return sign(|x| - |y|) */
     114                 :            : int
     115                 :  540550237 : absr_cmp(GEN x, GEN y)
     116                 :            : {
     117                 :            :   long ex,ey,lx,ly,lz,i;
     118                 :            : 
     119 [ +  + ][ +  + ]:  540550237 :   if (!signe(x)) return signe(y)? -1: 0;
     120         [ +  + ]:  512255463 :   if (!signe(y)) return 1;
     121                 :            : 
     122                 :  511800961 :   ex=expo(x); ey=expo(y);
     123         [ +  + ]:  511800961 :   if (ex>ey) return  1;
     124         [ +  + ]:  365142267 :   if (ex<ey) return -1;
     125                 :            : 
     126                 :  141941430 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     127 [ +  + ][ +  + ]:  225572387 :   i=2; while (i<lz && x[i]==y[i]) i++;
     128 [ +  + ][ +  + ]:  141941430 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     129         [ +  + ]:   23018961 :   if (lx>=ly)
     130                 :            :   {
     131 [ -  + ][ #  # ]:   23016608 :     while (i<lx && !x[i]) i++;
     132                 :   23016608 :     return (i==lx)? 0: 1;
     133                 :            :   }
     134 [ +  + ][ +  - ]:       4706 :   while (i<ly && !y[i]) i++;
     135         [ +  - ]:  540550237 :   return (i==ly)? 0: -1;
     136                 :            : }
     137                 :            : 

Generated by: LCOV version 1.9