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 19834-0e97742) Lines: 67 71 94.4 %
Date: 2016-12-09 05:49:11 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   116803608 : equalii(GEN x, GEN y)
      26             : {
      27   116803608 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      28    93771394 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      29             : }
      30             : 
      31             : int
      32   266360184 : cmpii(GEN x, GEN y)
      33             : {
      34   266360184 :   const long sx = signe(x), sy = signe(y);
      35   266360184 :   if (sx<sy) return -1;
      36   261991611 :   if (sx>sy) return 1;
      37   253743320 :   if (!sx) return 0;
      38   252054034 :   if (sx>0)
      39   240755349 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      40             :   else
      41    11298685 :     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   108554198 : cmprr(GEN x, GEN y)
      77             : {
      78   108554198 :   const long sx = signe(x), sy = signe(y);
      79             :   long ex,ey,lx,ly,lz,i;
      80             : 
      81   108554198 :   if (!sx) {
      82      179933 :     if (!sy || expo(x) >= expo(y)) return 0;
      83      142870 :     return sy > 0? -1: 1;
      84             :   }
      85   108374265 :   if (!sy) {
      86       81310 :     if (expo(y) >= expo(x)) return 0;
      87       80557 :     return sx > 0? 1: -1;
      88             :   }
      89   108292955 :   if (sx<sy) return -1;
      90   108286255 :   if (sx>sy) return 1;
      91             : 
      92   108263154 :   ex=expo(x); ey=expo(y);
      93   108263154 :   if (ex>ey) return sx;
      94    71308814 :   if (ex<ey) return -sx;
      95             : 
      96    39547473 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      97    39547473 :   i=2; while (i<lz && x[i]==y[i]) i++;
      98    39547473 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
      99    16221382 :   if (lx>=ly)
     100             :   {
     101    16221340 :     while (i<lx && !x[i]) i++;
     102    16221340 :     return (i==lx) ? 0 : sx;
     103             :   }
     104          42 :   while (i<ly && !y[i]) i++;
     105          42 :   return (i==ly) ? 0 : -sx;
     106             : }
     107             : 
     108             : /* x and y are integers. Return 1 if |x| == |y|, 0 otherwise */
     109             : int
     110     2668810 : absequalii(GEN x, GEN y)
     111             : {
     112     2668810 :   if (!signe(x)) return !signe(y);
     113     2664099 :   if (!signe(y)) return 0;
     114     2663539 :   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  1204680176 : abscmpii(GEN x, GEN y)
     120             : {
     121  1204680176 :   if (!signe(x)) return signe(y)? -1: 0;
     122  1182137238 :   if (!signe(y)) return 1;
     123  1121824467 :   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   471770839 : abscmprr(GEN x, GEN y)
     129             : {
     130             :   long ex,ey,lx,ly,lz,i;
     131             : 
     132   471770839 :   if (!signe(x)) return signe(y)? -1: 0;
     133   442707352 :   if (!signe(y)) return 1;
     134             : 
     135   442201383 :   ex=expo(x); ey=expo(y);
     136   442201383 :   if (ex>ey) return  1;
     137   309999893 :   if (ex<ey) return -1;
     138             : 
     139   129210391 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     140   129210391 :   i=2; while (i<lz && x[i]==y[i]) i++;
     141   129210391 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     142    23166334 :   if (lx>=ly)
     143             :   {
     144    23163929 :     while (i<lx && !x[i]) i++;
     145    23163929 :     return (i==lx)? 0: 1;
     146             :   }
     147        2405 :   while (i<ly && !y[i]) i++;
     148        2405 :   return (i==ly)? 0: -1;
     149             : }
     150             : 

Generated by: LCOV version 1.11