Replace () with (void) in function prototypes
[platform/core/system/dlog.git] / src / tests / test_ptrs_list_neg.c
1 /*
2  * Copyright (c) 2017-2020, Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "test_ptrs_list_wrap.c"
18
19 int main(void)
20 {
21         list_head head = NULL;
22         assert(list_count(head) == 0);
23
24         void *const elems[] = {"a", "b", "c"};
25
26         for (size_t i = 0; i < NELEMS(elems); i++) {
27                 assert(list_add(&head, elems[i]));
28                 assert(list_count(head) == i + 1);
29         }
30
31         fail_calloc = 7;
32         for (size_t i = 0; i < NELEMS(elems); i++) {
33                 assert(!list_add(&head, elems[i]));
34                 assert(list_count(head) == NELEMS(elems));
35         }
36
37         fail_copy_on = elems[0];
38         letters_cleared[0] = letters_cleared[1] = letters_cleared[2] = false;
39         assert(!list_map(head, NULL, copy_cb, clear_cb));
40         assert(!letters_cleared[0] && letters_cleared[1] && letters_cleared[2]);
41
42         /* list_map() has some tricky allocation inside it so
43          * make sure there were as many free()s as calloc()s */
44         fail_calloc = 1 << 28;
45         frees = 0;
46         fail_copy_on = elems[0];
47         assert(!list_map(head, NULL, copy_cb, NULL));
48         assert(frees == 2);
49         assert(fail_calloc == 1 << (28-2));
50         fail_copy_on = NULL;
51
52         list_clear(&head);
53         assert(list_count(head) == 0);
54         assert(head == NULL);
55
56         return 0;
57 }