File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,9 @@ name = "rle_decode"
35
35
path = " fuzz_targets/rle_decode.rs"
36
36
test = false
37
37
doc = false
38
+
39
+ [[bin ]]
40
+ name = " rle_encode"
41
+ path = " fuzz_targets/rle_encode.rs"
42
+ test = false
43
+ doc = false
Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+ use libfuzzer_sys:: fuzz_target;
3
+ use fvm_ipld_bitfield:: BitField ;
4
+ use arbitrary:: Arbitrary ;
5
+
6
+ #[ derive( Debug , Arbitrary ) ]
7
+ enum Operation {
8
+ Set ( u64 ) ,
9
+ Unset ( u64 ) ,
10
+ }
11
+
12
+ fuzz_target ! ( |data: ( BitField , Vec <Operation >) | {
13
+ let ( mut bf, ops) = data;
14
+
15
+ for op in ops {
16
+ match op {
17
+ Operation :: Set ( x) => { _ = bf. try_set( x) ; }
18
+ Operation :: Unset ( x) => { bf. unset( x) ; }
19
+ } ;
20
+ }
21
+
22
+ let bf_bytes = bf. to_bytes( ) ;
23
+ let bf2 = BitField :: from_bytes( & bf_bytes) . unwrap( ) ;
24
+ assert_eq!( bf, bf2) ;
25
+
26
+ let bf2_bytes = bf. to_bytes( ) ;
27
+ assert_eq!( bf_bytes, bf2_bytes) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments