LCOV - code coverage report
Current view: top level - example - example.c (source / functions) Hit Total Coverage
Test: Basic example ( view descriptions ) Lines: 9 10 90.0 %
Date: 2016-12-20 14:12:28 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 4 75.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  *  example.c
       3                 :            :  * 
       4                 :            :  *  Calculate the sum of a given range of integer numbers. The range is
       5                 :            :  *  specified by providing two integer numbers as command line argument.
       6                 :            :  *  If no arguments are specified, assume the predefined range [0..9].
       7                 :            :  *  Abort with an error message if the resulting number is too big to be
       8                 :            :  *  stored as int variable.
       9                 :            :  *
      10                 :            :  *  This program example is similar to the one found in the GCOV documentation.
      11                 :            :  *  It is used to demonstrate the HTML output generated by LCOV.
      12                 :            :  *
      13                 :            :  *  The program is split into 3 modules to better demonstrate the 'directory
      14                 :            :  *  overview' function. There are also a lot of bloated comments inserted to
      15                 :            :  *  artificially increase the source code size so that the 'source code
      16                 :            :  *  overview' function makes at least a minimum of sense.
      17                 :            :  *
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <stdio.h>
      21                 :            : #include <stdlib.h>
      22                 :            : #include "iterate.h"
      23                 :            : #include "gauss.h"
      24                 :            : 
      25                 :            : static int start = 0;
      26                 :            : static int end = 9;
      27                 :            : 
      28                 :            : 
      29                 :          3 : int main (int argc, char* argv[])
      30                 :            : {
      31                 :            :         int total1, total2;
      32                 :            : 
      33                 :            :         /* Accept a pair of numbers as command line arguments. */
      34                 :            : 
      35         [ +  + ]:          3 :         if (argc == 3)
      36                 :            :         {
      37                 :          2 :                 start   = atoi(argv[1]);
      38                 :          2 :                 end     = atoi(argv[2]);
      39                 :            :         }
      40                 :            : 
      41                 :            : 
      42                 :            :         /* Use both methods to calculate the result. */
      43                 :            : 
      44                 :          3 :         total1 = iterate_get_sum (start, end);
      45                 :          2 :         total2 = gauss_get_sum (start, end);
      46                 :            : 
      47                 :            : 
      48                 :            :         /* Make sure both results are the same. */
      49                 :            : 
      50         [ -  + ]:          2 :         if (total1 != total2)
      51                 :            :         {
      52                 :          0 :                 printf ("Failure (%d != %d)!\n", total1, total2);
      53                 :            :         }
      54                 :            :         else
      55                 :            :         {
      56                 :          2 :                 printf ("Success, sum[%d..%d] = %d\n", start, end, total1);
      57                 :            :         }
      58                 :            : 
      59                 :          2 :         return 0;
      60                 :            : }

Generated by: LCOV version 1.13