resetting manifest requested domain to floor
[platform/upstream/ccache.git] / test / test_counters.c
1 /*
2  * Copyright (C) 2010 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 TEST_SUITE(counters)
25
26 TEST(counters_init_0_should_allocate_0)
27 {
28         struct counters *counters = counters_init(0);
29
30         CHECK_UNS_EQ(0, counters->allocated);
31         CHECK_UNS_EQ(0, counters->size);
32
33         counters_free(counters);
34 }
35
36 TEST(counters_init_7_should_allocate_32)
37 {
38         int i;
39         struct counters *counters = counters_init(7);
40
41         CHECK_UNS_EQ(32, counters->allocated);
42         CHECK_UNS_EQ(7, counters->size);
43         for (i = 0; i < 7; i++) {
44                 CHECK_UNS_EQ(0, counters->data[i]);
45         }
46
47         counters_free(counters);
48 }
49
50 TEST(counters_resize_50_should_allocate_96)
51 {
52         struct counters *counters = counters_init(0);
53
54         CHECK_UNS_EQ(0, counters->allocated);
55         counters_resize(counters, 50);
56         CHECK_UNS_EQ(50, counters->size);
57         CHECK_UNS_EQ(96, counters->allocated);
58
59         counters_free(counters);
60 }
61
62 TEST_SUITE_END