Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / lcov / example / example.c
blobf9049aa64bafad3aad81910c355c625742290008
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.
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.
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.
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "iterate.h"
23 #include "gauss.h"
25 static int start = 0;
26 static int end = 9;
29 int main (int argc, char* argv[])
31 int total1, total2;
33 /* Accept a pair of numbers as command line arguments. */
35 if (argc == 3)
37 start = atoi(argv[1]);
38 end = atoi(argv[2]);
42 /* Use both methods to calculate the result. */
44 total1 = iterate_get_sum (start, end);
45 total2 = gauss_get_sum (start, end);
48 /* Make sure both results are the same. */
50 if (total1 != total2)
52 printf ("Failure (%d != %d)!\n", total1, total2);
54 else
56 printf ("Success, sum[%d..%d] = %d\n", start, end, total1);
59 return 0;