File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ debug = true
3131
3232[workspace .dependencies ]
3333jiter  = { path  = " crates/jiter"  , version  = " 0.5.0"   }
34+ batson  = { path  = " crates/batson"  , version  = " 0.5.0"   }
3435pyo3  = { version  = " 0.22.0"   }
3536pyo3-build-config  = { version  = " 0.22.0"   }
3637bencher  = " 0.1.5" 
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ serde = "1.0.190"
1515indexmap  = " 2.0.0" 
1616num-bigint  = " 0.4.4" 
1717num-traits  = " 0.2.17" 
18- jiter  = {path  = " ../jiter"  }
18+ jiter  = {workspace  = true }
19+ batson  = {workspace  = true }
1920
2021[[bin ]]
2122name  = " compare_to_serde" 
@@ -28,3 +29,9 @@ name = "compare_skip"
2829path  = " fuzz_targets/compare_skip.rs" 
2930test  = false 
3031doc  = false 
32+ 
33+ [[bin ]]
34+ name  = " batson_round_trip" 
35+ path  = " fuzz_targets/batson_round_trip.rs" 
36+ test  = false 
37+ doc  = false 
Original file line number Diff line number Diff line change 1+ #![ no_main]  
2+ 
3+ use  batson:: { batson_to_json_string,  encode_from_json} ; 
4+ use  jiter:: JsonValue ; 
5+ 
6+ use  libfuzzer_sys:: fuzz_target; 
7+ 
8+ fn  round_trip ( json :  String )  { 
9+     let  Ok ( jiter_value1)  = JsonValue :: parse ( json. as_bytes ( ) ,  false )  else  { 
10+         return ; 
11+     } ; 
12+     let  bytes1 = encode_from_json ( & jiter_value1) . unwrap ( ) ; 
13+     let  json1 = batson_to_json_string ( & bytes1) . unwrap ( ) ; 
14+ 
15+     let  jiter_value2 = JsonValue :: parse ( json1. as_bytes ( ) ,  false ) . unwrap ( ) ; 
16+     let  bytes2 = encode_from_json ( & jiter_value2) . unwrap ( ) ; 
17+     let  json2 = batson_to_json_string ( & bytes2) . unwrap ( ) ; 
18+ 
19+     assert_eq ! ( json1,  json2) ; 
20+ } 
21+ 
22+ fuzz_target ! ( |json:  String | { 
23+     round_trip( json) ; 
24+ } ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments