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 #include "../src/ccache.h"
18 #include "../src/counters.h"
19 #include "framework.h"
24 TEST(counters_init_0_should_allocate_0)
26 struct counters *counters = counters_init(0);
28 CHECK_INT_EQ(0, counters->allocated);
29 CHECK_INT_EQ(0, counters->size);
31 counters_free(counters);
34 TEST(counters_init_7_should_allocate_32)
37 struct counters *counters = counters_init(7);
39 CHECK_INT_EQ(32, counters->allocated);
40 CHECK_INT_EQ(7, counters->size);
41 for (i = 0; i < 7; i++) {
42 CHECK_INT_EQ(0, counters->data[i]);
45 counters_free(counters);
48 TEST(counters_resize_50_should_allocate_96)
50 struct counters *counters = counters_init(0);
52 CHECK_INT_EQ(0, counters->allocated);
53 counters_resize(counters, 50);
54 CHECK_INT_EQ(50, counters->size);
55 CHECK_INT_EQ(96, counters->allocated);
57 counters_free(counters);