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) Coverage Total Hit
Test: PARI/GP v2.18.1 lcov report (development 31053-95e3b72995) Lines: 95.8 % 71 68
Test Date: 2026-07-24 17:03:07 Functions: 100.0 % 7 7
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; either version 2 of the License, or (at your option) any later
       9              : version. It is distributed in the hope that it will be useful, but WITHOUT
      10              : ANY WARRANTY WHATSOEVER.
      11              : 
      12              : Check the License for details. You should have received a copy of it, along
      13              : with the package; see the file 'COPYING'. If not, write to the Free Software
      14              : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      15              : 
      16              : 
      17              : /********************************************************************/
      18              : /**                                                                **/
      19              : /**                      Comparison routines                       **/
      20              : /**                                                                **/
      21              : /********************************************************************/
      22              : 
      23              : /*They depend on cmpiispec and equaliispec in mp.c*/
      24              : 
      25              : int
      26    520861147 : equalii(GEN x, GEN y)
      27              : {
      28    520861147 :   if ((x[1] & (LGBITS|SIGNBITS)) != (y[1] & (LGBITS|SIGNBITS))) return 0;
      29    481518521 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      30              : }
      31              : 
      32              : int
      33    644958594 : cmpii(GEN x, GEN y)
      34              : {
      35    644958594 :   const long sx = signe(x), sy = signe(y);
      36    644958594 :   if (sx<sy) return -1;
      37    632757629 :   if (sx>sy) return 1;
      38    617878529 :   if (!sx) return 0;
      39    607381158 :   if (sx>0)
      40    588054731 :     return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      41              :   else
      42     19326427 :     return -cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
      43              : }
      44              : 
      45              : int
      46       257744 : equalrr(GEN x, GEN y)
      47              : {
      48              :   long lx, ly, i;
      49              : 
      50       257744 :   if (!signe(x)) {
      51          196 :     if (!signe(y)) return 1; /* all zeroes are equal */
      52           49 :     return expo(x) >= expo(y);
      53              :   }
      54       257548 :   if (!signe(y))
      55           42 :     return expo(y) >= expo(x);
      56              : 
      57       257506 :   if (x[1] != y[1]) return 0;
      58              : 
      59       253884 :   lx = lg(x);
      60       253884 :   ly = lg(y);
      61       253884 :   if (lx < ly)
      62              :   {
      63            7 :     i=2; while (i<lx && x[i]==y[i]) i++;
      64            7 :     if (i<lx) return 0;
      65            0 :     for (; i < ly; i++) if (y[i]) return 0;
      66              :   }
      67              :   else
      68              :   {
      69       417067 :     i=2; while (i<ly && x[i]==y[i]) i++;
      70       253877 :     if (i<ly) return 0;
      71        19257 :     for (; i < lx; i++) if (x[i]) return 0;
      72              :   }
      73        19257 :   return 1;
      74              : }
      75              : 
      76              : int
      77    151169881 : cmprr(GEN x, GEN y)
      78              : {
      79    151169881 :   const long sx = signe(x), sy = signe(y);
      80              :   long ex,ey,lx,ly,lz,i;
      81              : 
      82    151169881 :   if (!sx) {
      83       282373 :     if (!sy || expo(x) >= expo(y)) return 0;
      84       172539 :     return sy > 0? -1: 1;
      85              :   }
      86    150887508 :   if (!sy) {
      87       722246 :     if (expo(y) >= expo(x)) return 0;
      88       722103 :     return sx > 0? 1: -1;
      89              :   }
      90    150165262 :   if (sx<sy) return -1;
      91    149907462 :   if (sx>sy) return 1;
      92              : 
      93    149870779 :   ex=expo(x); ey=expo(y);
      94    149870779 :   if (ex>ey) return sx;
      95     88639081 :   if (ex<ey) return -sx;
      96              : 
      97     45023540 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
      98    130217395 :   i=2; while (i<lz && x[i]==y[i]) i++;
      99     45023540 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i]) ? sx : -sx;
     100     24066118 :   if (lx>=ly)
     101              :   {
     102     24065441 :     while (i<lx && !x[i]) i++;
     103     24065441 :     return (i==lx) ? 0 : sx;
     104              :   }
     105          737 :   while (i<ly && !y[i]) i++;
     106          677 :   return (i==ly) ? 0 : -sx;
     107              : }
     108              : 
     109              : /* x and y are integers. Return 1 if |x| == |y|, 0 otherwise */
     110              : int
     111     58595499 : absequalii(GEN x, GEN y)
     112              : {
     113     58595499 :   if (!signe(x)) return !signe(y);
     114     58594029 :   if (!signe(y)) return 0;
     115     58593742 :   return equaliispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     116              : }
     117              : 
     118              : /* x and y are integers. Return sign(|x| - |y|) */
     119              : int
     120   2659379354 : abscmpii(GEN x, GEN y)
     121              : {
     122   2659379354 :   if (!signe(x)) return signe(y)? -1: 0;
     123   2255487176 :   if (!signe(y)) return 1;
     124   1900781426 :   return cmpiispec(x+2, y+2, lgefint(x)-2, lgefint(y)-2);
     125              : }
     126              : 
     127              : /* x and y are reals. Return sign(|x| - |y|) */
     128              : int
     129    334269759 : abscmprr(GEN x, GEN y)
     130              : {
     131              :   long ex,ey,lx,ly,lz,i;
     132              : 
     133    334269759 :   if (!signe(x)) return signe(y)? -1: 0;
     134    333587997 :   if (!signe(y)) return 1;
     135              : 
     136    333347824 :   ex=expo(x); ey=expo(y);
     137    333347824 :   if (ex>ey) return  1;
     138    215512060 :   if (ex<ey) return -1;
     139              : 
     140    136541433 :   lx=lg(x); ly=lg(y); lz = (lx<ly)?lx:ly;
     141    255384772 :   i=2; while (i<lz && x[i]==y[i]) i++;
     142    136541433 :   if (i<lz) return ((ulong)x[i] > (ulong)y[i])? 1: -1;
     143     33200941 :   if (lx>=ly)
     144              :   {
     145     33200941 :     while (i<lx && !x[i]) i++;
     146     33200941 :     return (i==lx)? 0: 1;
     147              :   }
     148            0 :   while (i<ly && !y[i]) i++;
     149            0 :   return (i==ly)? 0: -1;
     150              : }
     151              : 
        

Generated by: LCOV version 2.0-1