LCOV - code coverage report
Current view: top level - ccache/test - test_stats.c (source / functions) Hit Total Coverage
Test: ccache.lcov.info Lines: 15 15 100.0 %
Date: 2015-06-29 Functions: 1 1 100.0 %
Branches: 7 12 58.3 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2010-2011 Joel Rosdahl
       3                 :            :  *
       4                 :            :  * This program is free software; you can redistribute it and/or modify it
       5                 :            :  * under the terms of the GNU General Public License as published by the Free
       6                 :            :  * Software Foundation; either version 3 of the License, or (at your option)
       7                 :            :  * any later version.
       8                 :            :  *
       9                 :            :  * This program is distributed in the hope that it will be useful, but WITHOUT
      10                 :            :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11                 :            :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
      12                 :            :  * more details.
      13                 :            :  *
      14                 :            :  * You should have received a copy of the GNU General Public License along with
      15                 :            :  * this program; if not, write to the Free Software Foundation, Inc., 51
      16                 :            :  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      17                 :            :  */
      18                 :            : 
      19                 :            : /*
      20                 :            :  * This file contains tests for statistics handling.
      21                 :            :  */
      22                 :            : 
      23                 :            : #include "ccache.h"
      24                 :            : #include "counters.h"
      25                 :            : #include "test/framework.h"
      26                 :            : #include "test/util.h"
      27                 :            : 
      28                 :          1 : TEST_SUITE(stats)
      29                 :            : 
      30         [ +  - ]:          1 : TEST(forward_compatibility)
      31                 :            : {
      32                 :            :         unsigned i;
      33                 :            :         FILE *f;
      34                 :          1 :         struct counters *counters = counters_init(0);
      35                 :            : 
      36                 :          1 :         f = fopen("stats", "w");
      37         [ +  + ]:        101 :         for (i = 0; i < 100; i++) {
      38                 :        100 :                 fprintf(f, "%u\n", i);
      39                 :            :         }
      40                 :          1 :         fclose(f);
      41                 :            : 
      42                 :          1 :         stats_read("stats", counters);
      43         [ -  + ]:          1 :         CHECK_INT_EQ(100, counters->size);
      44         [ -  + ]:          1 :         CHECK_INT_EQ(73, counters->data[73]);
      45                 :            : 
      46                 :          1 :         stats_write("stats", counters);
      47         [ -  + ]:          1 :         CHECK_INT_EQ(100, counters->size);
      48         [ -  + ]:          1 :         CHECK_INT_EQ(99, counters->data[99]);
      49                 :            : 
      50                 :          1 :         counters_free(counters);
      51                 :            : }
      52                 :            : 
      53                 :          1 : TEST_SUITE_END

Generated by: LCOV version 1.9