1 // Copyright (C) 2010-2018 Joel Rosdahl
3 // This program is free software; you can redistribute it and/or modify it
4 // under the terms of the GNU General Public License as published by the Free
5 // Software Foundation; either version 3 of the License, or (at your option)
8 // This program is distributed in the hope that it will be useful, but WITHOUT
9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 // You should have received a copy of the GNU General Public License along with
14 // this program; if not, write to the Free Software Foundation, Inc., 51
15 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 // This file contains tests for statistics handling.
19 #include "../src/ccache.h"
20 #include "../src/counters.h"
21 #include "framework.h"
26 TEST(forward_compatibility)
30 struct counters *counters = counters_init(0);
32 f = fopen("stats", "w");
33 for (i = 0; i < 100; i++) {
34 fprintf(f, "%u\n", i);
38 stats_read("stats", counters);
39 CHECK_INT_EQ(100, counters->size);
40 CHECK_INT_EQ(73, counters->data[73]);
42 stats_write("stats", counters);
43 CHECK_INT_EQ(100, counters->size);
44 CHECK_INT_EQ(99, counters->data[99]);
46 counters_free(counters);