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 - kernel/none - cmp.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 20916-a74d914) Lines: 67 71 94.4 %
Date: 2017-08-18 06:23:59 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   250732269 : equalii(GEN x, GEN y)
      26             : {
      27   250732269 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      28   225615968 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      29             : }
      30             : 
      31             : int
      32   390342400 : cmpii(GEN x, GEN y)
      33             : {
      34   390342400 :   const long sx = signe(x), sy = signe(y);
      35   390342400 :   if (sx<sy) return -1;
      36   385781502 :   if (sx>sy) return 1;
      37   377480506 :   if (!sx) return 0;
      38   375514883 :   if (sx>0)
      39   364184009 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      40             :   else
      41    11330874 :     return -cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      42             : }
      43             : 
      44             : int
      45        1650 : equalrr(GEN x, GEN y)
      46             : {
      47             :   long lx, ly, i;
      48             : 
      49        1650 :   if (!signe(x)) {
      50         140 :     if (!signe(y)) return 1; /* all zeroes are equal */
      51          14 :     return expo(x) >= expo(y);
      52             :   }
      53        1510 :   if (!signe(y))
      54           0 :     return expo(y) >= expo(x);
      55             : 
      56        1510 :   if (x[1] != y[1]) return 0;
      57             : 
      58        1176 :   lx = lg(x);
      59        1176 :   ly = lg(y);
      60        1176 :   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        1176 :     i=2; while (i<ly && x[i]==y[i]) i++;
      69        1176 :     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   100135714 : cmprr(GEN x, GEN y)
      77             : {
      78   100135714 :   const long sx = signe(x), sy = signe(y);
      79             :   long ex,ey,lx,ly,lz,i;
      80             : 
      81   100135714 :   if (!sx) {
      82      176810 :     if (!sy || expo(x) >= expo(y)) return 0;
      83      139543 :     return sy > 0? -1: 1;
      84             :   }
      85    99958904 :   if (!sy) {
      86       91828 :     if (expo(y) >= expo(x)) return 0;
      87       91087 :     return sx > 0? 1: -1;
      88             :   }
      89    99867076 :   if (sx<sy) return -1;
      90    99853101 :   if (sx>sy) return 1;
      91             : 
      92    99826701 :   ex=expo(x); ey=expo(y);
      93    99826701 :   if (ex>ey) return sx;
      94    66363315 :   if (ex<ey) return -sx;
      95             : 
      96    36744940 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      97    36744940 :   i=2; while (i<lz && x[i]==y[i]) i++;
      98    36744940 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
      99    14528152 :   if (lx>=ly)
     100             :   {
     101    14528104 :     while (i<lx && !x[i]) i++;
     102    14528104 :     return (i==lx) ? 0 : sx;
     103             :   }
     104          48 :   while (i<ly && !y[i]) i++;
     105          48 :   return (i==ly) ? 0 : -sx;
     106             : }
     107             : 
     108             : /* x and y are integers. Return 1 if |x| == |y|, 0 otherwise */
     109             : int
     110     2683159 : absequalii(GEN x, GEN y)
     111             : {
     112     2683159 :   if (!signe(x)) return !signe(y);
     113     2678448 :   if (!signe(y)) return 0;
     114     2677888 :   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  1273144193 : abscmpii(GEN x, GEN y)
     120             : {
     121  1273144193 :   if (!signe(x)) return signe(y)? -1: 0;
     122  1248432935 :   if (!signe(y)) return 1;
     123  1175170466 :   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   451370667 : abscmprr(GEN x, GEN y)
     129             : {
     130             :   long ex,ey,lx,ly,lz,i;
     131             : 
     132   451370667 :   if (!signe(x)) return signe(y)? -1: 0;
     133   421895664 :   if (!signe(y)) return 1;
     134             : 
     135   421354375 :   ex=expo(x); ey=expo(y);
     136   421354375 :   if (ex>ey) return  1;
     137   298283987 :   if (ex<ey) return -1;
     138             : 
     139   122160117 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     140   122160117 :   i=2; while (i<lz && x[i]==y[i]) i++;
     141   122160117 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     142    20808748 :   if (lx>=ly)
     143             :   {
     144    20806018 :     while (i<lx && !x[i]) i++;
     145    20806018 :     return (i==lx)? 0: 1;
     146             :   }
     147        2730 :   while (i<ly && !y[i]) i++;
     148        2730 :   return (i==ly)? 0: -1;
     149             : }
     150             : 

Generated by: LCOV version 1.11