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 20459-9710128) Lines: 65 71 91.5 %
Date: 2017-04-27 05:33:52 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   100307505 : equalii(GEN x, GEN y)
      26             : {
      27   100307505 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      28    80182542 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      29             : }
      30             : 
      31             : int
      32   237297302 : cmpii(GEN x, GEN y)
      33             : {
      34   237297302 :   const long sx = signe(x), sy = signe(y);
      35   237297302 :   if (sx<sy) return -1;
      36   233501359 :   if (sx>sy) return 1;
      37   226417296 :   if (!sx) return 0;
      38   224758651 :   if (sx>0)
      39   215061421 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      40             :   else
      41     9697230 :     return -cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      42             : }
      43             : 
      44             : int
      45        1416 : equalrr(GEN x, GEN y)
      46             : {
      47             :   long lx, ly, i;
      48             : 
      49        1416 :   if (!signe(x)) {
      50         120 :     if (!signe(y)) return 1; /* all zeroes are equal */
      51          12 :     return expo(x) >= expo(y);
      52             :   }
      53        1296 :   if (!signe(y))
      54           0 :     return expo(y) >= expo(x);
      55             : 
      56        1296 :   if (x[1] != y[1]) return 0;
      57             : 
      58        1008 :   lx = lg(x);
      59        1008 :   ly = lg(y);
      60        1008 :   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        1008 :     i=2; while (i<ly && x[i]==y[i]) i++;
      69        1008 :     if (i<ly) return 0;
      70         984 :     for (; i < lx; i++) if (x[i]) return 0;
      71             :   }
      72         984 :   return 1;
      73             : }
      74             : 
      75             : int
      76    92638482 : cmprr(GEN x, GEN y)
      77             : {
      78    92638482 :   const long sx = signe(x), sy = signe(y);
      79             :   long ex,ey,lx,ly,lz,i;
      80             : 
      81    92638482 :   if (!sx) {
      82      154404 :     if (!sy || expo(x) >= expo(y)) return 0;
      83      122514 :     return sy > 0? -1: 1;
      84             :   }
      85    92484078 :   if (!sy) {
      86       70308 :     if (expo(y) >= expo(x)) return 0;
      87       69594 :     return sx > 0? 1: -1;
      88             :   }
      89    92413770 :   if (sx<sy) return -1;
      90    92405910 :   if (sx>sy) return 1;
      91             : 
      92    92384430 :   ex=expo(x); ey=expo(y);
      93    92384430 :   if (ex>ey) return sx;
      94    60891591 :   if (ex<ey) return -sx;
      95             : 
      96    33847986 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      97    33847986 :   i=2; while (i<lz && x[i]==y[i]) i++;
      98    33847986 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
      99    13901919 :   if (lx>=ly)
     100             :   {
     101    13901877 :     while (i<lx && !x[i]) i++;
     102    13901877 :     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     2287584 : absequalii(GEN x, GEN y)
     111             : {
     112     2287584 :   if (!signe(x)) return !signe(y);
     113     2283546 :   if (!signe(y)) return 0;
     114     2283066 :   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  1094630197 : abscmpii(GEN x, GEN y)
     120             : {
     121  1094630197 :   if (!signe(x)) return signe(y)? -1: 0;
     122  1075565110 :   if (!signe(y)) return 1;
     123  1023137486 :   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   401888355 : abscmprr(GEN x, GEN y)
     129             : {
     130             :   long ex,ey,lx,ly,lz,i;
     131             : 
     132   401888355 :   if (!signe(x)) return signe(y)? -1: 0;
     133   377671854 :   if (!signe(y)) return 1;
     134             : 
     135   377234952 :   ex=expo(x); ey=expo(y);
     136   377234952 :   if (ex>ey) return  1;
     137   264349713 :   if (ex<ey) return -1;
     138             : 
     139   110389578 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     140   110389578 :   i=2; while (i<lz && x[i]==y[i]) i++;
     141   110389578 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     142    19854810 :   if (lx>=ly)
     143             :   {
     144    19854810 :     while (i<lx && !x[i]) i++;
     145    19854810 :     return (i==lx)? 0: 1;
     146             :   }
     147           0 :   while (i<ly && !y[i]) i++;
     148           0 :   return (i==ly)? 0: -1;
     149             : }
     150             : 

Generated by: LCOV version 1.11