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 : : #include "ccache.h"
20 : : #include "counters.h"
21 : : #include "test/framework.h"
22 : : #include "test/util.h"
23 : :
24 : 1 : TEST_SUITE(counters)
25 : :
26 [ + - ]: 1 : TEST(counters_init_0_should_allocate_0)
27 : : {
28 : 1 : struct counters *counters = counters_init(0);
29 : :
30 [ - + ]: 1 : CHECK_INT_EQ(0, counters->allocated);
31 [ - + ]: 1 : CHECK_INT_EQ(0, counters->size);
32 : :
33 : 1 : counters_free(counters);
34 : : }
35 : :
36 [ + - ]: 1 : TEST(counters_init_7_should_allocate_32)
37 : : {
38 : : int i;
39 : 1 : struct counters *counters = counters_init(7);
40 : :
41 [ - + ]: 1 : CHECK_INT_EQ(32, counters->allocated);
42 [ - + ]: 1 : CHECK_INT_EQ(7, counters->size);
43 [ + + ]: 8 : for (i = 0; i < 7; i++) {
44 [ - + ]: 7 : CHECK_INT_EQ(0, counters->data[i]);
45 : : }
46 : :
47 : 1 : counters_free(counters);
48 : : }
49 : :
50 [ + - ]: 1 : TEST(counters_resize_50_should_allocate_96)
51 : : {
52 : 1 : struct counters *counters = counters_init(0);
53 : :
54 [ - + ]: 1 : CHECK_INT_EQ(0, counters->allocated);
55 : 1 : counters_resize(counters, 50);
56 [ - + ]: 1 : CHECK_INT_EQ(50, counters->size);
57 [ - + ]: 1 : CHECK_INT_EQ(96, counters->allocated);
58 : :
59 : 1 : counters_free(counters);
60 : : }
61 : :
62 : 1 : TEST_SUITE_END
|