Line | Count | Source |
1 | | // Copyright 2021 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | // |
15 | | //////////////////////////////////////////////////////////////////////////////// |
16 | | |
17 | | #include <stdint.h> |
18 | | #include <string.h> |
19 | | #include <stdlib.h> |
20 | | #include "roaring/roaring.h" |
21 | | |
22 | 647 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size){ |
23 | 647 | roaring_statistics_t stats; |
24 | 647 | bool answer = true; |
25 | 647 | roaring_bitmap_t* bitmap = roaring_bitmap_portable_deserialize_safe(data, size); |
26 | 647 | if(bitmap) { |
27 | | /* |
28 | | uint64_t card1 = roaring_bitmap_get_cardinality(bitmap); |
29 | | roaring_bitmap_statistics(bitmap, &stats); |
30 | | unsigned universe_size = stats.max_value + 1; |
31 | | roaring_bitmap_t *inverted = roaring_bitmap_flip(bitmap, 0U, universe_size); |
32 | | if(inverted) { |
33 | | roaring_bitmap_t *double_inverted = roaring_bitmap_flip(inverted, 0U, universe_size); |
34 | | if(double_inverted) |
35 | | { |
36 | | answer = (roaring_bitmap_get_cardinality(inverted) + roaring_bitmap_get_cardinality(bitmap) == universe_size); |
37 | | if (answer) answer = roaring_bitmap_equals(bitmap, double_inverted); |
38 | | if (!answer) { |
39 | | printf("Bad flip\n\nbitmap1:\n"); |
40 | | roaring_bitmap_printf_describe(bitmap); // debug |
41 | | printf("\n\nflipped:\n"); |
42 | | roaring_bitmap_printf_describe(inverted); // debug |
43 | | } |
44 | | roaring_bitmap_free(double_inverted); |
45 | | } |
46 | | roaring_bitmap_free(inverted); |
47 | | }*/ |
48 | 122 | roaring_bitmap_free(bitmap); |
49 | 122 | } |
50 | 647 | return 0; |
51 | 647 | } |