fn roundtrip_random<E: Engine>(
    byte_buf: &mut Vec<u8>,
    str_buf: &mut String,
    engine: &E,
    byte_len: usize,
    approx_values_per_byte: u8,
    max_rounds: u64,
) {
    // let the short ones be short but don't let it get too crazy large
    let num_rounds = calculate_number_of_rounds(byte_len, approx_values_per_byte, max_rounds);
    let mut r = rand::rngs::SmallRng::from_entropy();
    let mut decode_buf = Vec::new();

    for _ in 0..num_rounds {
        byte_buf.clear();
        str_buf.clear();
        decode_buf.clear();
        while byte_buf.len() < byte_len {
            byte_buf.push(r.gen::<u8>());
        }

        encode_engine_string(&byte_buf, str_buf, engine);
        decode_engine_vec(&str_buf, &mut decode_buf, engine).unwrap();

        assert_eq!(byte_buf, &decode_buf);
    }
}
// generate random contents of the specified length and test encode/decode roundtrip
generate random contents of the specified length and test encode/decode roundtrip
generate random contents of the specified length and test encode / decode roundtrip
fn roundtrip_random<E: Engine>(
    byte_buf: &mut Vec<u8>,
    str_buf: &mut String,
    engine: &E,
    byte_len: usize,
    approx_values_per_byte: u8,
    max_rounds: u64,
) {
    // let the short ones be short but don't let it get too crazy large
    let num_rounds = calculate_number_of_rounds(byte_len, approx_values_per_byte, max_rounds);
    let mut r = rand::rngs::SmallRng::from_entropy();
    let mut decode_buf = Vec::new();
    for _ in 0..num_rounds {
        byte_buf.clear();
        str_buf.clear();
        decode_buf.clear();
        while byte_buf.len() < byte_len {
            byte_buf.push(r.gen::<u8>());
        }
        encode_engine_string(&byte_buf, str_buf, engine);
        decode_engine_vec(&str_buf, &mut decode_buf, engine).unwrap();
        assert_eq!(byte_buf, &decode_buf);
    }
}
fn roundtrip_random < E : Engine > ( byte_buf : & mut Vec < u8 > , str_buf : & mut String , engine : & E , byte_len : usize , approx_values_per_byte : u8 , max_rounds : u64 , ) { // let the short ones be short but don't let it get too crazy large let num_rounds = calculate_number_of_rounds ( byte_len , approx_values_per_byte , max_rounds ) ; let mut r = rand :: rngs :: SmallRng :: from_entropy ( ) ; let mut decode_buf = Vec :: new ( ) ; for _ in 0 .. num_rounds { byte_buf . clear ( ) ; str_buf . clear ( ) ; decode_buf . clear ( ) ; while byte_buf . len ( ) < byte_len { byte_buf . push ( r . gen :: < u8 > ( ) ) ; } encode_engine_string ( & byte_buf , str_buf , engine ) ; decode_engine_vec ( & str_buf , & mut decode_buf , engine ) . unwrap ( ) ; assert_eq ! ( byte_buf decode_buf ) ; } }
generate random contents of the specified length and test encode/decode roundtrip
generate random contents of the specified length and test encode / decode roundtrip
byte_buf
&mut Vec<u8>
str_buf
&mut String
engine
&E
byte_len
usize
approx_values_per_byte
u8
max_rounds
u64
byte_buf
&mut Vec<u8>
str_buf
&mut String
engine
&E
byte_len
usize
approx_values_per_byte
u8
max_rounds
u64