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 to exceed 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.12.0 lcov report (development 23156-1ff82ca01) Lines: 67 71 94.4 %
Date: 2018-10-15 05:38:28 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          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   236558992 : equalii(GEN x, GEN y)
      26             : {
      27   236558992 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      28   207496693 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      29             : }
      30             : 
      31             : int
      32   296301350 : cmpii(GEN x, GEN y)
      33             : {
      34   296301350 :   const long sx = signe(x), sy = signe(y);
      35   296301350 :   if (sx<sy) return -1;
      36   291445706 :   if (sx>sy) return 1;
      37   282480715 :   if (!sx) return 0;
      38   279317098 :   if (sx>0)
      39   267264168 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      40             :   else
      41    12052930 :     return -cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      42             : }
      43             : 
      44             : int
      45        2035 : equalrr(GEN x, GEN y)
      46             : {
      47             :   long lx, ly, i;
      48             : 
      49        2035 :   if (!signe(x)) {
      50         133 :     if (!signe(y)) return 1; /* all zeroes are equal */
      51          14 :     return expo(x) >= expo(y);
      52             :   }
      53        1902 :   if (!signe(y))
      54           0 :     return expo(y) >= expo(x);
      55             : 
      56        1902 :   if (x[1] != y[1]) return 0;
      57             : 
      58        1211 :   lx = lg(x);
      59        1211 :   ly = lg(y);
      60        1211 :   if (lx < ly)
      61             :   {
      62           0 :     i=2; while (i<lx && x[i]==y[i]) i++;
      63           0 :     if (i<lx) return 0;
      64           0 :     for (; i < ly; i++) if (y[i]) return 0;
      65             :   }
      66             :   else
      67             :   {
      68        1211 :     i=2; while (i<ly && x[i]==y[i]) i++;
      69        1211 :     if (i<ly) return 0;
      70        1148 :     for (; i < lx; i++) if (x[i]) return 0;
      71             :   }
      72        1148 :   return 1;
      73             : }
      74             : 
      75             : int
      76   115225899 : cmprr(GEN x, GEN y)
      77             : {
      78   115225899 :   const long sx = signe(x), sy = signe(y);
      79             :   long ex,ey,lx,ly,lz,i;
      80             : 
      81   115225899 :   if (!sx) {
      82      214948 :     if (!sy || expo(x) >= expo(y)) return 0;
      83      177568 :     return sy > 0? -1: 1;
      84             :   }
      85   115010951 :   if (!sy) {
      86      101594 :     if (expo(y) >= expo(x)) return 0;
      87      100866 :     return sx > 0? 1: -1;
      88             :   }
      89   114909357 :   if (sx<sy) return -1;
      90   114891513 :   if (sx>sy) return 1;
      91             : 
      92   114863748 :   ex=expo(x); ey=expo(y);
      93   114863748 :   if (ex>ey) return sx;
      94    74534058 :   if (ex<ey) return -sx;
      95             : 
      96    39471044 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      97    39471044 :   i=2; while (i<lz && x[i]==y[i]) i++;
      98    39471044 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
      99    16449416 :   if (lx>=ly)
     100             :   {
     101    16449367 :     while (i<lx && !x[i]) i++;
     102    16449367 :     return (i==lx) ? 0 : sx;
     103             :   }
     104          49 :   while (i<ly && !y[i]) i++;
     105          49 :   return (i==ly) ? 0 : -sx;
     106             : }
     107             : 
     108             : /* x and y are integers. Return 1 if |x| == |y|, 0 otherwise */
     109             : int
     110     2841794 : absequalii(GEN x, GEN y)
     111             : {
     112     2841794 :   if (!signe(x)) return !signe(y);
     113     2786515 :   if (!signe(y)) return 0;
     114     2784387 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     115             : }
     116             : 
     117             : /* x and y are integers. Return sign(|x| - |y|) */
     118             : int
     119  1061314532 : abscmpii(GEN x, GEN y)
     120             : {
     121  1061314532 :   if (!signe(x)) return signe(y)? -1: 0;
     122   988083477 :   if (!signe(y)) return 1;
     123   906395414 :   return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     124             : }
     125             : 
     126             : /* x and y are reals. Return sign(|x| - |y|) */
     127             : int
     128   505908335 : abscmprr(GEN x, GEN y)
     129             : {
     130             :   long ex,ey,lx,ly,lz,i;
     131             : 
     132   505908335 :   if (!signe(x)) return signe(y)? -1: 0;
     133   468022969 :   if (!signe(y)) return 1;
     134             : 
     135   467294155 :   ex=expo(x); ey=expo(y);
     136   467294155 :   if (ex>ey) return  1;
     137   325708441 :   if (ex<ey) return -1;
     138             : 
     139   131013856 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     140   131013856 :   i=2; while (i<lz && x[i]==y[i]) i++;
     141   131013856 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     142    23383815 :   if (lx>=ly)
     143             :   {
     144    23377853 :     while (i<lx && !x[i]) i++;
     145    23377853 :     return (i==lx)? 0: 1;
     146             :   }
     147        5962 :   while (i<ly && !y[i]) i++;
     148        5962 :   return (i==ly)? 0: -1;
     149             : }
     150             : 

Generated by: LCOV version 1.13